Skip to content

debug build.yml

debug build.yml #426

Workflow file for this run

# GitHub Actions Workflow created for testing and preparing the plugin release in following steps:
# - validate Gradle Wrapper,
# - run test and verifyPlugin tasks,
# - run buildPlugin task and prepare artifact for the further tests,
# - create a draft release.
#
# Workflow is triggered on push and pull_request events.
#
# Docs:
# - GitHub Actions: https://help.github.com/en/actions
##
name: Build
on: [ push, pull_request ]
jobs:
check:
name: Check
runs-on: ubuntu-latest
strategy:
matrix:
language: [ 'java' ]
steps:
- uses: actions/setup-java@v4
with:
distribution: 'zulu'
java-version: 17
- uses: actions/checkout@v4
- uses: gradle/[email protected]
# CodeQL initialization
- name: Initialize CodeQL
uses: github/codeql-action/init@v3
with:
languages: ${{ matrix.language }}
# Cache Gradle dependencies
- name: Setup Gradle Dependencies Cache
uses: actions/[email protected]
with:
path: ~/.gradle/caches
key: ${{ runner.os }}-gradle-caches-${{ hashFiles('**/*.gradle', '**/*.gradle.kts', 'gradle.properties') }}
# Cache Gradle Wrapper
- name: Setup Gradle Wrapper Cache
uses: actions/[email protected]
with:
path: ~/.gradle/wrapper
key: ${{ runner.os }}-gradle-wrapper-${{ hashFiles('**/gradle/wrapper/gradle-wrapper.properties') }}
# Run detekt, ktlint and tests
- name: Run Linters and Test
run: ./gradlew check
# upload test results in case of tests failure
- uses: actions/upload-artifact@v4
if: failure()
with:
name: test-results
path: |
build/reports/tests/
build/test-results/
# Run verifyPlugin Gradle task
- name: Verify Plugin
run: ./gradlew verifyPlugin
# Security scan with CodeQL
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v3
# upload test results in case of tests failure
- uses: actions/upload-artifact@v4
with:
name: distrib
path: |
build/distributions/
# Build plugin with buildPlugin Gradle task and provide the artifact for the next workflow jobs
# Requires test job to be passed
build:
name: Build
needs: check
runs-on: ubuntu-latest
outputs:
name: ${{ steps.properties.outputs.name }}
version: ${{ steps.properties.outputs.version }}
changelog: ${{ steps.properties.outputs.changelog }}
artifact: ${{ steps.properties.outputs.artifact }}
steps:
- uses: actions/setup-java@v4
with:
distribution: 'zulu'
java-version: 17
- uses: actions/checkout@v4
# Cache Gradle Dependencies
- name: Setup Gradle Dependencies Cache
uses: actions/[email protected]
with:
path: ~/.gradle/caches
key: ${{ runner.os }}-gradle-caches-${{ hashFiles('**/*.gradle', '**/*.gradle.kts', 'gradle.properties') }}
# Cache Gradle Wrapper
- name: Setup Gradle Wrapper Cache
uses: actions/[email protected]
with:
path: ~/.gradle/wrapper
key: ${{ runner.os }}-gradle-wrapper-${{ hashFiles('**/gradle/wrapper/gradle-wrapper.properties') }}
# Cache Plugin distribution
- name: Setup Plugin distribution Cache
uses: actions/[email protected]
with:
path: ./build/distributions
key: ${{ runner.os }}-plugin-distribution
# Set environment variables
- name: Export Properties
id: properties
shell: bash
run: |
PROPERTIES="$(./gradlew properties --console=plain -q)"
VERSION="$(echo "$PROPERTIES" | grep "^version:" | cut -f2- -d ' ')"
NAME="$(echo "$PROPERTIES" | grep "^name:" | cut -f2- -d ' ')"
CHANGELOG="$(./gradlew getChangelog --unreleased --no-header --console=plain -q)"
ARTIFACT="${NAME}-${VERSION}.zip"
echo "version=$VERSION" >> $GITHUB_OUTPUT
echo "name=$NAME" >> $GITHUB_OUTPUT
echo 'changelog<<EOF' >> $GITHUB_OUTPUT
echo "$CHANGELOG" >> $GITHUB_OUTPUT
echo 'EOF' >> $GITHUB_OUTPUT
echo "artifact=$ARTIFACT" >> $GITHUB_OUTPUT
# Build artifact using buildPlugin Gradle task
- name: Build Plugin
run: ./gradlew buildPlugin
# upload test results in case of tests failure
- uses: actions/upload-artifact@v4
with:
name: distrib2
path: |
build/distributions/
# Prepare a pre-release for GitHub Releases page for the manual verification
# Use manual promote release workflow to create final release
preRelease:
name: Pre release
if: github.event_name != 'pull_request' && contains(github.ref, 'master')
needs: [ build ]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
# Cache Plugin distribution
- name: Setup Plugin distribution Cache
uses: actions/[email protected]
with:
path: ./build/distributions
key: ${{ runner.os }}-plugin-distribution
# upload test results in case of tests failure
- uses: actions/upload-artifact@v4
with:
name: distrib3
path: |
build/distributions/
# Delete existing release if needed
- name: Delete previous release
id: deletePreviousRelease
uses: dev-drprasad/[email protected]
continue-on-error: true
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
tag_name: ${{ needs.build.outputs.version }}
# Create new pre-release - which is not publicly visible and requires manual acceptance
- name: Create Pre Release
id: createPreRelease
uses: ncipollo/release-action@v1
with:
allowUpdates: true
prerelease: true
name: ${{ needs.build.outputs.version }}
tag: ${{ needs.build.outputs.version }}
commit: ${{ env.GITHUB_SHA }}
body: ${{ needs.build.outputs.changelog }}
artifacts: ./build/distributions/${{ needs.build.outputs.artifact }}
artifactContentType: application/zip
token: ${{ secrets.GITHUB_TOKEN }}