From ea13d06ecc7d173eaf1704ef545b6ddf2f623a5e Mon Sep 17 00:00:00 2001 From: George Gastaldi Date: Tue, 15 Oct 2024 21:50:20 -0300 Subject: [PATCH] Reusable Release workflow --- .github/workflows/pre-release.yml | 25 +----- .github/workflows/release-binaries.yml.bak | 86 ------------------ .github/workflows/release-perform.yml | 61 +++++++++++++ .github/workflows/release-prepare.yml | 18 ++++ .github/workflows/release.yml | 100 --------------------- 5 files changed, 83 insertions(+), 207 deletions(-) delete mode 100644 .github/workflows/release-binaries.yml.bak create mode 100644 .github/workflows/release-perform.yml create mode 100644 .github/workflows/release-prepare.yml delete mode 100644 .github/workflows/release.yml diff --git a/.github/workflows/pre-release.yml b/.github/workflows/pre-release.yml index 0a9e64e..afe17b3 100644 --- a/.github/workflows/pre-release.yml +++ b/.github/workflows/pre-release.yml @@ -9,25 +9,8 @@ concurrency: group: ${{ github.workflow }}-${{ github.ref }} cancel-in-progress: true -defaults: - run: - shell: bash - jobs: - release: - runs-on: ubuntu-latest - name: pre release - - steps: - - uses: radcortez/project-metadata-action@master - name: retrieve project metadata - id: metadata - with: - github-token: ${{secrets.GITHUB_TOKEN}} - metadata-file-path: '.github/project.yml' - - - name: Validate version - if: contains(steps.metadata.outputs.current-version, 'SNAPSHOT') - run: | - echo '::error::Cannot release a SNAPSHOT version.' - exit 1 \ No newline at end of file + pre-release: + name: Pre-Release + uses: quarkiverse/.github/.github/workflows/pre-release.yml@main + secrets: inherit diff --git a/.github/workflows/release-binaries.yml.bak b/.github/workflows/release-binaries.yml.bak deleted file mode 100644 index 2044c31..0000000 --- a/.github/workflows/release-binaries.yml.bak +++ /dev/null @@ -1,86 +0,0 @@ -name: Build Playpen CLI Binaries - -on: - workflow_run: - workflows: ["Playpen Release"] - types: - - completed - -defaults: - run: - shell: bash - -jobs: - cli-binary: - name: Quarkus CLI binary on ${{ matrix.os }} - runs-on: ${{ matrix.os }} - strategy: - matrix: - os: [ macos-latest, ubuntu-latest ] - steps: - - uses: actions/checkout@v4 - with: - fetch-depth: 0 - fetch-tags: true - - - name: read-yaml-file - uses: pietrobolcato/action-read-yaml@1.1.0 - id: project - with: - config: ${{ github.workspace }}/.github/project.yml - - - uses: graalvm/setup-graalvm@v1 - with: - java-version: '21' - distribution: 'graalvm' - github-token: ${{ secrets.GITHUB_TOKEN }} - native-image-job-reports: 'true' - - - name: Build CLI Binaries ${{ steps.project.outputs['release.current-version'] }} - run: | - git checkout ${{ steps.project.outputs['release.current-version'] }} - mvn clean install -DskipTests=true -Dnative -pl :playpen-core,:kubernetes-playpen-core,:playpen-cli - mv cli/target/playpen-cli-*-runner playpen.${{ matrix.os }} - - - name: Release binary ${{ steps.project.outputs['release.current-version'] }} - uses: softprops/action-gh-release@v2 - with: - tag_name: ${{ steps.project.outputs['release.current-version'] }} - files: playpen.${{ matrix.os }} - windows-cli-binary: - name: Quarkus CLI binary on Windows - runs-on: ${{ matrix.os }} - strategy: - matrix: - os: [ windows-latest ] - steps: - - uses: actions/checkout@v4 - with: - fetch-depth: 0 - fetch-tags: true - - - name: read-yaml-file - uses: pietrobolcato/action-read-yaml@1.1.0 - id: project - with: - config: ${{ github.workspace }}/.github/project.yml - - - uses: graalvm/setup-graalvm@v1 - with: - java-version: '21' - distribution: 'graalvm' - github-token: ${{ secrets.GITHUB_TOKEN }} - native-image-job-reports: 'true' - - - name: Build CLI Binaries ${{ steps.project.outputs['release.current-version'] }} - run: | - git checkout ${{ steps.project.outputs['release.current-version'] }} - mvn clean install -DskipTests=true -Dnative -pl :playpen-core,:kubernetes-playpen-core,:playpen-cli - mv cli/target/playpen-cli-*-runner.exe playpen.${{ matrix.os }}.exe - - - name: Release binary ${{ steps.project.outputs['release.current-version'] }} - uses: softprops/action-gh-release@v2 - with: - tag_name: ${{ steps.project.outputs['release.current-version'] }} - files: playpen.${{ matrix.os }}.exe - diff --git a/.github/workflows/release-perform.yml b/.github/workflows/release-perform.yml new file mode 100644 index 0000000..b027888 --- /dev/null +++ b/.github/workflows/release-perform.yml @@ -0,0 +1,61 @@ +name: Quarkiverse Perform Release +run-name: Perform ${{github.event.inputs.tag || github.ref_name}} Release +on: + push: + tags: + - '*' + workflow_dispatch: + inputs: + tag: + description: 'Tag to release' + required: true + +permissions: + attestations: write + id-token: write + contents: read + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +jobs: + perform-release: + name: Perform Release + uses: quarkiverse/.github/.github/workflows/perform-release.yml@main + secrets: inherit + with: + version: ${{github.event.inputs.tag || github.ref_name}} + + cli-binary: + name: Quarkus CLI binary on ${{ matrix.os }} + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: [ macos-latest, ubuntu-latest, windows-latest ] + steps: + - uses: actions/checkout@v4 + with: + ref: ${{github.event.inputs.tag || github.ref_name}} + fetch-depth: 0 + + - uses: graalvm/setup-graalvm@v1 + with: + java-version: '21' + distribution: 'graalvm' + github-token: ${{ secrets.GITHUB_TOKEN }} + native-image-job-reports: 'true' + + - name: Build CLI Binaries ${{github.event.inputs.tag || github.ref_name}} + run: | + mvn clean install -DskipTests=true -Dnative -pl :playpen-core,:kubernetes-playpen-core,:playpen-cli + mv cli/target/playpen-cli-*-runner${{ matrix.os == 'windows-latest' && '.exe' || '' }} ${FILE} + env: + FILE: playpen.${{ matrix.os }}${{ matrix.os == 'windows-latest' && '.exe' || '' }} + + - name: Upload binary ${{github.event.inputs.tag || github.ref_name}} + run: gh release upload ${TAG} ${FILE} + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + TAG: ${{github.event.inputs.tag || github.ref_name}} + FILE: playpen.${{ matrix.os }}${{ matrix.os == 'windows-latest' && '.exe' || '' }} diff --git a/.github/workflows/release-prepare.yml b/.github/workflows/release-prepare.yml new file mode 100644 index 0000000..aedad93 --- /dev/null +++ b/.github/workflows/release-prepare.yml @@ -0,0 +1,18 @@ +name: Quarkiverse Prepare Release + +on: + pull_request: + types: [ closed ] + paths: + - '.github/project.yml' + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +jobs: + prepare-release: + name: Prepare Release + if: ${{ github.event.pull_request.merged == true}} + uses: quarkiverse/.github/.github/workflows/prepare-release.yml@main + secrets: inherit diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml deleted file mode 100644 index 959d0a9..0000000 --- a/.github/workflows/release.yml +++ /dev/null @@ -1,100 +0,0 @@ -name: Playpen Release - -on: - pull_request: - types: [closed] - paths: - - '.github/project.yml' - -concurrency: - group: ${{ github.workflow }}-${{ github.ref }} - cancel-in-progress: true - -defaults: - run: - shell: bash - -jobs: - release: - runs-on: ubuntu-latest - name: release - if: ${{github.event.pull_request.merged == true}} - outputs: - tag: ${{ steps.metadata.outputs.current-version }} - steps: - - uses: radcortez/project-metadata-action@main - name: Retrieve project metadata - id: metadata - with: - github-token: ${{secrets.GITHUB_TOKEN}} - metadata-file-path: '.github/project.yml' - - - uses: actions/checkout@v4 - - - name: Set up JDK 17 - uses: actions/setup-java@v4 - with: - distribution: temurin - java-version: 17 - cache: 'maven' - server-id: ossrh - server-username: MAVEN_USERNAME - server-password: MAVEN_PASSWORD - gpg-private-key: ${{ secrets.GPG_PRIVATE_KEY }} - gpg-passphrase: MAVEN_GPG_PASSPHRASE - - - name: Configure Git author - run: | - git config --local user.email "action@github.com" - git config --local user.name "GitHub Action" - - - name: Maven release ${{steps.metadata.outputs.current-version}} - run: | - find -name '*.md' -exec sed -i 's/${{steps.metadata.outputs.next-version}}/${{steps.metadata.outputs.current-version}}/g' {} + - find -name '*.md' -exec sed -i 's|raw.githubusercontent.com/quarkiverse/quarkus-playpen/main|raw.githubusercontent.com/quarkiverse/quarkus-playpen/${{steps.metadata.outputs.current-version}}|g' {} + - git commit -a -m "Bump doc to current version" - mvn -B release:prepare -Prelease -DreleaseVersion=${{steps.metadata.outputs.current-version}} -DdevelopmentVersion=${{steps.metadata.outputs.next-version}} - mvn -B release:perform -Darguments=-DperformRelease -DperformRelease -Prelease - find -name '*.md' -exec sed -i 's|raw.githubusercontent.com/quarkiverse/quarkus-playpen/${{steps.metadata.outputs.current-version}}|raw.githubusercontent.com/quarkiverse/quarkus-playpen/main|g' {} + - find -name '*.md' -exec sed -i 's/${{steps.metadata.outputs.current-version}}/${{steps.metadata.outputs.next-version}}/g' {} + - git commit -a -m "Bump doc to next-version" - env: - MAVEN_USERNAME: ${{ secrets.OSSRH_USERNAME }} - MAVEN_PASSWORD: ${{ secrets.OSSRH_TOKEN }} - MAVEN_GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }} - - - name: Push changes to ${{github.base_ref}} branch - run: | - git push - git push origin ${{steps.metadata.outputs.current-version}} - cli-binary: - name: Quarkus CLI binary on ${{ matrix.os }} - runs-on: ${{ matrix.os }} - needs: release - strategy: - matrix: - os: [ macos-latest, ubuntu-latest, windows-latest ] - steps: - - uses: actions/checkout@v4 - with: - fetch-depth: 0 - fetch-tags: true - - - uses: graalvm/setup-graalvm@v1 - with: - java-version: '21' - distribution: 'graalvm' - github-token: ${{ secrets.GITHUB_TOKEN }} - native-image-job-reports: 'true' - - - name: Build CLI Binaries ${{ needs.release.outputs.tag }} - run: | - git checkout ${{ needs.release.outputs.tag }} - mvn clean install -DskipTests=true -Dnative -pl :playpen-core,:kubernetes-playpen-core,:playpen-cli - mv cli/target/playpen-cli-*-runner${{ matrix.os == 'windows-latest' && '.exe' || '' }} playpen.${{ matrix.os }}${{ matrix.os == 'windows-latest' && '.exe' || '' }} - - - name: Release binary ${{ needs.release.outputs.tag }} - uses: softprops/action-gh-release@v2 - with: - tag_name: ${{ needs.release.outputs.tag }} - files: playpen.${{ matrix.os }}${{ matrix.os == 'windows-latest' && '.exe' || '' }}