From 47ded1f172924b896d193bad1d48f4c2af382f24 Mon Sep 17 00:00:00 2001 From: Andres Almiray Date: Sun, 13 Mar 2022 12:08:50 +0100 Subject: [PATCH] [build] Update workflow configuration --- .github/workflows/build.yml | 16 ++-- .github/workflows/early-access.yml | 65 +++++++++------ .github/workflows/release.yml | 126 +++++++++++++++-------------- 3 files changed, 115 insertions(+), 92 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index a7fe30f1b..4b106463c 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -3,6 +3,10 @@ name: Build on: pull_request: +env: + JAVA_VERSION: '11' + JAVA_DISTRO: 'zulu' + jobs: build: name: Build @@ -16,25 +20,25 @@ jobs: steps: - uses: actions/checkout@v2 - - name: Set up Java + - name: Setup Java uses: actions/setup-java@v2 with: - java-version: 11 - distribution: 'zulu' + java-version: ${{ env.JAVA_VERSION }} + distribution: ${{ env.JAVA_DISTRO }} - uses: actions/cache@v2 with: path: ~/.gradle/caches - key: ${{ runner.os }}-gradle-cache-${{ hashFiles('**/*.gradle') }}-${{ hashFiles('**/gradle.properties') }} + key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle') }}-${{ hashFiles('**/gradle.properties') }} restore-keys: | ${{ runner.os }}-gradle- - uses: actions/cache@v2 with: path: ~/.gradle/wrapper - key: ${{ runner.os }}-gradle-wrapper-${{ hashFiles('**/gradlew') }} + key: ${{ runner.os }}-gradlew-${{ hashFiles('**/gradlew') }} restore-keys: | ${{ runner.os }}-gradlew- - name: Build - run: ./gradlew build -S + run: ./gradlew build -S \ No newline at end of file diff --git a/.github/workflows/early-access.yml b/.github/workflows/early-access.yml index 56e6a9148..f786641a4 100644 --- a/.github/workflows/early-access.yml +++ b/.github/workflows/early-access.yml @@ -4,44 +4,68 @@ on: push: branches: [ master ] +env: + JAVA_VERSION: '11' + JAVA_DISTRO: 'zulu' + jobs: + precheck: + name: Precheck + if: startsWith(github.event.head_commit.message, 'Releasing version') != true + runs-on: ubuntu-latest + outputs: + VERSION: ${{ steps.vars.outputs.VERSION }} + steps: + - name: Checkout + uses: actions/checkout@v2 + + - uses: n1hility/cancel-previous-runs@v2 + with: + token: ${{ secrets.GITHUB_TOKEN }} + + - name: Version + id: vars + shell: bash + run: | + echo ::set-output name=VERSION::$(cat VERSION) + build: name: Build + needs: [precheck] + if: endsWith(${{ needs.precheck.outputs.VERSION }}, '-SNAPSHOT') strategy: fail-fast: false matrix: os: [ ubuntu-latest, macos-latest, windows-latest ] runs-on: ${{ matrix.os }} - if: github.repository == 'kordamp/ikonli' && startsWith(github.event.head_commit.message, 'Releasing version') != true - steps: - uses: actions/checkout@v2 - - name: Set up Java + - name: Setup Java uses: actions/setup-java@v2 with: - java-version: 11 - distribution: 'zulu' + java-version: ${{ env.JAVA_VERSION }} + distribution: ${{ env.JAVA_DISTRO }} - uses: actions/cache@v2 with: path: ~/.gradle/caches - key: ${{ runner.os }}-gradle-cache-${{ hashFiles('**/*.gradle') }}-${{ hashFiles('**/gradle.properties') }} + key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle') }}-${{ hashFiles('**/gradle.properties') }} restore-keys: | ${{ runner.os }}-gradle- - uses: actions/cache@v2 with: path: ~/.gradle/wrapper - key: ${{ runner.os }}-gradle-wrapper-${{ hashFiles('**/gradlew') }} + key: ${{ runner.os }}-gradlew-${{ hashFiles('**/gradlew') }} restore-keys: | ${{ runner.os }}-gradlew- - name: Build run: ./gradlew -Prelease=true build - - name: Jlink & JPackage - run: './gradlew -Prelease=true :ikonli-browser:jlinkZip :ikonli-browser:jpackage' + - name: Assemble + run: ./gradlew -Prelease=true :ikonli-browser:jlinkZip :ikonli-browser:jpackage - name: Upload artifacts uses: actions/upload-artifact@v2 @@ -57,9 +81,9 @@ jobs: apps/ikonli-browser/build/packagers/ikonli-browser-*.pkg apps/ikonli-browser/build/packagers/ikonli-browser-*.deb - earlyaccess: - name: EarlyAccess - needs: build + release: + name: Release + needs: [precheck, build] runs-on: ubuntu-latest steps: - name: Checkout @@ -70,18 +94,11 @@ jobs: - name: Download build artifacts uses: actions/download-artifact@v2 - - name: Artifacts - run: ls -lR artifacts - - - name: Set up Java + - name: Setup Java uses: actions/setup-java@v2 with: - java-version: 11 - distribution: 'zulu' - - - name: Version - id: vars - run: echo ::set-output name=version::$(cat VERSION) + java-version: ${{ env.JAVA_VERSION }} + distribution: ${{ env.JAVA_DISTRO }} - name: Release uses: jreleaser/release-action@v1 @@ -89,7 +106,7 @@ jobs: version: early-access arguments: full-release -P artifactsDir=artifacts env: - JRELEASER_PROJECT_VERSION: ${{ steps.vars.outputs.version }} + JRELEASER_PROJECT_VERSION: ${{ needs.precheck.outputs.VERSION }} JRELEASER_GITHUB_TOKEN: ${{ secrets.GIT_ACCESS_TOKEN }} JRELEASER_GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }} JRELEASER_GPG_PUBLIC_KEY: ${{ secrets.GPG_PUBLIC_KEY }} @@ -99,7 +116,7 @@ jobs: if: always() uses: actions/upload-artifact@v2 with: - name: jreleaser + name: jreleaser-release path: | out/jreleaser/trace.log out/jreleaser/output.properties diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index b3a4421d3..96041c186 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -4,40 +4,36 @@ on: workflow_dispatch: inputs: version: - description: "Release version" + description: 'Release version' required: true +env: + JAVA_VERSION: '11' + JAVA_DISTRO: 'zulu' + jobs: - version: - name: Version + precheck: + name: Precheck runs-on: ubuntu-latest - if: github.repository == 'kordamp/ikonli' - + outputs: + VERSION: ${{ steps.vars.outputs.VERSION }} steps: - - uses: actions/checkout@v2 - - - name: Set release version - run: | - VERSION=${{ github.event.inputs.version }} - echo $VERSION > VERSION - sed -i -e "s/^\:project-version\:\ .*/:project-version: ${VERSION}/g" README.adoc - git add VERSION - git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com" - git config --global user.name "GitHub Action" - git commit -a -m "Releasing version $VERSION" - git push origin master - git rev-parse HEAD > HEAD + - name: Checkout + uses: actions/checkout@v2 - - name: Upload files - uses: actions/upload-artifact@v2 + - uses: n1hility/cancel-previous-runs@v2 with: - name: artifacts - path: | - HEAD + token: ${{ secrets.GITHUB_TOKEN }} + + - name: Version + id: vars + shell: bash + run: | + echo ::set-output name=VERSION::${{ github.event.inputs.version }} build: name: Build - needs: version + needs: [precheck] strategy: fail-fast: false matrix: @@ -45,45 +41,38 @@ jobs: runs-on: ${{ matrix.os }} steps: - - name: Download all artifacts - uses: actions/download-artifact@v2 - - - name: Read HEAD ref - id: head - uses: juliangruber/read-file-action@v1 - with: - path: artifacts/HEAD - - name: Check out repository uses: actions/checkout@v2 - with: - ref: ${{ steps.head.outputs.content }} - - name: Set up Java + - name: Setup Java uses: actions/setup-java@v2 with: - java-version: 11 - distribution: 'zulu' + java-version: ${{ env.JAVA_VERSION }} + distribution: ${{ env.JAVA_DISTRO }} - uses: actions/cache@v2 with: path: ~/.gradle/caches - key: ${{ runner.os }}-gradle-cache-${{ hashFiles('**/*.gradle') }}-${{ hashFiles('**/gradle.properties') }} + key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle') }}-${{ hashFiles('**/gradle.properties') }} restore-keys: | ${{ runner.os }}-gradle- - uses: actions/cache@v2 with: path: ~/.gradle/wrapper - key: ${{ runner.os }}-gradle-wrapper-${{ hashFiles('**/gradlew') }} + key: ${{ runner.os }}-gradlew-${{ hashFiles('**/gradlew') }} restore-keys: | ${{ runner.os }}-gradlew- + - name: Version + run: | + echo ${{ needs.precheck.outputs.VERSION }} > VERSION + - name: Build run: ./gradlew -Prelease=true build - - name: Jlink & JPackage - run: './gradlew -Prelease=true :ikonli-browser:jlinkZip :ikonli-browser:jpackage' + - name: Assemble + run: ./gradlew -Prelease=true :ikonli-browser:jlinkZip :ikonli-browser:jpackage - name: Upload artifacts uses: actions/upload-artifact@v2 @@ -101,33 +90,46 @@ jobs: release: name: Release - needs: build + needs: [precheck, build] runs-on: ubuntu-latest steps: - # must read HEAD before checkout - - name: Download build artifacts - uses: actions/download-artifact@v2 - - - name: Read HEAD ref - id: head - uses: juliangruber/read-file-action@v1 - with: - path: artifacts/HEAD - - name: Checkout uses: actions/checkout@v2 with: - ref: ${{ steps.head.outputs.content }} fetch-depth: 0 - name: Download build artifacts uses: actions/download-artifact@v2 - - name: Set up Java + - name: Setup Java uses: actions/setup-java@v2 with: - java-version: 11 - distribution: 'zulu' + java-version: ${{ env.JAVA_VERSION }} + distribution: ${{ env.JAVA_DISTRO }} + + - uses: actions/cache@v2 + with: + path: ~/.gradle/caches + key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle') }}-${{ hashFiles('**/gradle.properties') }} + restore-keys: | + ${{ runner.os }}-gradle- + + - uses: actions/cache@v2 + with: + path: ~/.gradle/wrapper + key: ${{ runner.os }}-gradlew-${{ hashFiles('**/gradlew') }} + restore-keys: | + ${{ runner.os }}-gradlew- + + - name: Version + run: | + echo ${{ needs.precheck.outputs.VERSION }} > VERSION + git add VERSION + sed -i -e "s/^\:project-version\:\ .*/:project-version: ${{ needs.precheck.outputs.VERSION }}/g" README.adoc + git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com" + git config --global user.name "GitHub Action" + git commit -a -m "Releasing version ${{ needs.precheck.outputs.VERSION }}" + git push origin master - name: Deploy env: @@ -138,14 +140,14 @@ jobs: ./gradlew -Prelease=true -Pfull-release=true \ -PsonatypeUsername=${{ secrets.SONATYPE_USERNAME }} \ -PsonatypePassword=${{ secrets.SONATYPE_PASSWORD }} \ - build publishToSonatype closeAndReleaseSonatypeStagingRepository -S + build :ikonli-bom:publishToSonatype publishToSonatype closeAndReleaseSonatypeStagingRepository -S - name: Release uses: jreleaser/release-action@v1 with: arguments: full-release -P artifactsDir=artifacts env: - JRELEASER_PROJECT_VERSION: ${{ github.event.inputs.version }} + JRELEASER_PROJECT_VERSION: ${{ needs.precheck.outputs.VERSION }} JRELEASER_GITHUB_TOKEN: ${{ secrets.GIT_ACCESS_TOKEN }} JRELEASER_GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }} JRELEASER_GPG_PUBLIC_KEY: ${{ secrets.GPG_PUBLIC_KEY }} @@ -155,11 +157,11 @@ jobs: JRELEASER_TWITTER_ACCESS_TOKEN: ${{ secrets.TWITTER_ACCESS_TOKEN }} JRELEASER_TWITTER_ACCESS_TOKEN_SECRET: ${{ secrets.TWITTER_ACCESS_TOKEN_SECRET }} - - name: JReleaser output + - name: JReleaser release output if: always() uses: actions/upload-artifact@v2 with: - name: artifact + name: jreleaser-release path: | out/jreleaser/trace.log - out/jreleaser/output.properties + out/jreleaser/output.properties \ No newline at end of file