[pre-commit.ci] pre-commit autoupdate (#33) #57
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Build | |
on: | |
push: | |
branches: [main] | |
pull_request: | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} | |
cancel-in-progress: true | |
jobs: | |
build: | |
name: Build plugin | |
runs-on: ubuntu-latest | |
outputs: | |
version: ${{ steps.properties.outputs.version }} | |
changelog: ${{ steps.properties.outputs.changelog }} | |
pluginVerifierHomeDir: ${{ steps.properties.outputs.pluginVerifierHomeDir }}qq | |
steps: | |
- name: Checkout git repository | |
uses: actions/checkout@v4 | |
- name: Set up Java | |
uses: actions/setup-java@v4 | |
with: | |
distribution: zulu | |
java-version: 17 | |
- name: Set up Gradle | |
uses: gradle/actions/setup-gradle@v4 | |
- name: Build plugin | |
run: ./gradlew --console=plain buildPlugin | |
- name: Prepare Plugin Artifact | |
id: artifact | |
shell: bash | |
run: | | |
cd ${{ github.workspace }}/build/distributions | |
FILENAME=`ls *.zip` | |
unzip "$FILENAME" -d content | |
echo "filename=${FILENAME:0:-4}" >> $GITHUB_OUTPUT | |
- name: Upload artifact for later download | |
uses: actions/upload-artifact@v4 | |
with: | |
name: ${{ steps.artifact.outputs.filename }} | |
path: ./build/distributions/content/*/* | |
- name: Export plugin properties | |
id: properties | |
shell: bash | |
run: | | |
PROPERTIES="$(./gradlew properties --console=plain -q)" | |
VERSION="$(echo "$PROPERTIES" | grep "^version:" | cut -f2- -d ' ')" | |
echo "version=$VERSION" >> $GITHUB_OUTPUT | |
echo "pluginVerifierHomeDir=~/.pluginVerifier" >> $GITHUB_OUTPUT | |
CHANGELOG="$(./gradlew getChangelog --unreleased --no-header --console=plain -q)" | |
echo "changelog<<EOF" >> $GITHUB_OUTPUT | |
echo "$CHANGELOG" >> $GITHUB_OUTPUT | |
echo "EOF" >> $GITHUB_OUTPUT | |
verify: | |
name: Verify plugin | |
needs: [build] | |
runs-on: ubuntu-latest | |
steps: | |
- name: Maximize Build Space | |
uses: jlumbroso/free-disk-space@main | |
with: | |
tool-cache: false | |
large-packages: false | |
- name: Checkout git repository | |
uses: actions/checkout@v4 | |
- name: Set up Java | |
uses: actions/setup-java@v4 | |
with: | |
distribution: zulu | |
java-version: 17 | |
- name: Set up Gradle | |
uses: gradle/actions/setup-gradle@v4 | |
with: | |
validate-wrappers: false | |
- name: Set up verifier cache | |
uses: actions/cache@v4 | |
with: | |
path: ${{ needs.build.outputs.pluginVerifierHomeDir }}/ides | |
key: plugin-verifier-${{ hashFiles('build/listProductsReleases.txt') }} | |
- name: Run verification | |
run: ./gradlew verifyPlugin -Dplugin.verifier.home.dir=${{ needs.build.outputs.pluginVerifierHomeDir }} | |
- name: Collect verification result | |
if: ${{ always() }} | |
uses: actions/upload-artifact@v4 | |
with: | |
name: pluginVerifier-result | |
path: ${{ github.workspace }}/build/reports/pluginVerifier | |
test: | |
name: Run tests | |
needs: [build] | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout git repository | |
uses: actions/checkout@v4 | |
- name: Set up Java | |
uses: actions/setup-java@v4 | |
with: | |
distribution: zulu | |
java-version: 17 | |
- name: Set up Gradle | |
uses: gradle/actions/setup-gradle@v4 | |
with: | |
validate-wrappers: false | |
- name: Run linter | |
run: ./gradlew ktlintCheck | |
releaseDraft: | |
name: Create release draft | |
if: github.event_name != 'pull_request' | |
needs: [build, test, verify] | |
runs-on: ubuntu-latest | |
permissions: | |
contents: write | |
steps: | |
- name: Checkout git repository | |
uses: actions/checkout@v4 | |
- name: Remove old release drafts | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
run: | | |
gh api repos/{owner}/{repo}/releases --jq '.[] | select(.draft == true) | .id' \ | |
| xargs -I '{}' gh api -X DELETE repos/{owner}/{repo}/releases/{} | |
- name: Create release draft | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
run: | | |
gh release create "v${{ needs.build.outputs.version }}" \ | |
--draft \ | |
--title "v${{ needs.build.outputs.version }}" \ | |
--notes "$(cat << 'EOM' | |
${{ needs.build.outputs.changelog }} | |
EOM | |
)" |