From 4c0c8c368bd31c0579775a59d697cc3c97e0cc37 Mon Sep 17 00:00:00 2001 From: Roberto Cortez Date: Thu, 5 Dec 2024 18:59:08 +0000 Subject: [PATCH] Update Release workflow --- .github/workflows/prepare-release.yml | 47 +++++++++ .github/workflows/publish-gradle.yml | 30 ++++++ .github/workflows/release.yml | 99 ++++++------------- .../{pre-release.yml => review-release.yml} | 8 +- .github/workflows/update-milestone.yml | 17 ++++ 5 files changed, 133 insertions(+), 68 deletions(-) create mode 100644 .github/workflows/prepare-release.yml create mode 100644 .github/workflows/publish-gradle.yml rename .github/workflows/{pre-release.yml => review-release.yml} (72%) create mode 100644 .github/workflows/update-milestone.yml diff --git a/.github/workflows/prepare-release.yml b/.github/workflows/prepare-release.yml new file mode 100644 index 000000000..c0e5ced97 --- /dev/null +++ b/.github/workflows/prepare-release.yml @@ -0,0 +1,47 @@ +name: SmallRye Prepare Release + +on: + pull_request: + types: [ closed ] + paths: + - '.github/project.yml' + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +permissions: + contents: write + +jobs: + prepare-gradle: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + + - name: git author + run: | + git config --global user.name "SmallRye CI" + git config --global user.email "smallrye@googlegroups.com" + + - uses: radcortez/project-metadata-action@main + name: retrieve project metadata + id: metadata + with: + github-token: ${{secrets.GITHUB_TOKEN}} + metadata-file-path: '.github/project.yml' + + - name: Prepare Gradle + run: | + echo "version=${{steps.metadata.outputs.current-version}}" > tools/gradle-plugin/gradle.properties + git add tools/gradle-plugin/gradle.properties + git commit -m "Update Gradle plugin version" + git push + + prepare-release: + needs: [prepare-gradle] + name: Prepare Release + if: ${{ github.event.pull_request.merged == true}} + uses: smallrye/.github/.github/workflows/prepare-release.yml@main + secrets: inherit diff --git a/.github/workflows/publish-gradle.yml b/.github/workflows/publish-gradle.yml new file mode 100644 index 000000000..02dfd65b4 --- /dev/null +++ b/.github/workflows/publish-gradle.yml @@ -0,0 +1,30 @@ +name: Publish Gradle + +on: + workflow_call: + inputs: + version: + required: true + description: Tag version to perform release + type: string + +jobs: + publish-gradle: + name: Publish Gradle + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + name: checkout ${{inputs.version}} + with: + ref: ${{inputs.version}} + + - uses: actions/setup-java@v4 + with: + distribution: 'temurin' + java-version: 11 + + - name: gradle release ${{inputs.version}} + run: | + mkdir -p ~/.gradle ; echo -e "gradle.publish.key=${{secrets.GRADLE_PUBLISH_KEY}}\ngradle.publish.secret=${{secrets.GRADLE_PUBLISH_SECRET}}" > ~/.gradle/gradle.properties + cd tools/gradle-plugin && gradle publishPlugins diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index a0b44e18a..c354f28af 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,71 +1,36 @@ name: SmallRye Release - +run-name: Perform ${{github.event.inputs.tag || github.ref_name}} Release on: - pull_request: - types: [closed] - paths: - - '.github/project.yml' + push: + tags: + - '*' + workflow_dispatch: + inputs: + tag: + description: 'Tag to release' + required: true + +permissions: + attestations: write + id-token: write + # Needed for the publish-* workflows + contents: write + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true jobs: - release: - runs-on: ubuntu-latest - name: release - if: ${{github.event.pull_request.merged == true}} - env: - GITHUB_TOKEN: ${{secrets.RELEASE_TOKEN}} - - 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@v2 - with: - token: ${{secrets.RELEASE_TOKEN}} - - - uses: actions/setup-java@v1.4.3 - with: - java-version: 17 - server-id: 'oss.sonatype' - server-username: 'MAVEN_DEPLOY_USERNAME' - server-password: 'MAVEN_DEPLOY_TOKEN' - gpg-private-key: ${{secrets.MAVEN_GPG_PRIVATE_KEY}} - gpg-passphrase: 'MAVEN_GPG_PASSPHRASE' - - - name: Install graphviz - run: sudo apt install graphviz - - - name: maven release ${{steps.metadata.outputs.current-version}} - env: - MAVEN_DEPLOY_USERNAME: ${{secrets.MAVEN_DEPLOY_USERNAME}} - MAVEN_DEPLOY_TOKEN: ${{secrets.MAVEN_DEPLOY_TOKEN}} - MAVEN_GPG_PASSPHRASE: ${{secrets.MAVEN_GPG_PASSPHRASE}} - run: | - java -version - git config --global user.name "SmallRye CI" - git config --global user.email "smallrye@googlegroups.com" - git checkout -b release - # update gradle version plugin - echo "version=${{steps.metadata.outputs.current-version}}" > tools/gradle-plugin/gradle.properties - git add tools/gradle-plugin/gradle.properties - git commit -m "Update Gradle plugin version" - mvn -X -e -B release:prepare -Prelease -DreleaseVersion=${{steps.metadata.outputs.current-version}} -DdevelopmentVersion=${{steps.metadata.outputs.next-version}} - git checkout ${{github.base_ref}} - git rebase release - mvn -X -e -B release:perform -Prelease - git push - git push --tags - - - name: Gradle plugin release ${{steps.metadata.outputs.current-version}} - run: | - mkdir -p ~/.gradle ; echo -e "gradle.publish.key=${{secrets.GRADLE_PUBLISH_KEY}}\ngradle.publish.secret=${{secrets.GRADLE_PUBLISH_SECRET}}" > ~/.gradle/gradle.properties - cd tools/gradle-plugin && gradle publishPlugins - - - uses: radcortez/milestone-release-action@main - name: milestone release - with: - github-token: ${{secrets.GITHUB_TOKEN}} - milestone-title: ${{steps.metadata.outputs.current-version}} \ No newline at end of file + perform-release: + name: Perform Release + uses: smallrye/.github/.github/workflows/perform-release.yml@main + secrets: inherit + with: + version: ${{github.event.inputs.tag || github.ref_name}} + + publish-gradle: + name: Publish Gradle + uses: ./.github/workflows/publish-gradle.yml + secrets: inherit + with: + version: ${{github.event.inputs.tag || github.ref_name}} diff --git a/.github/workflows/pre-release.yml b/.github/workflows/review-release.yml similarity index 72% rename from .github/workflows/pre-release.yml rename to .github/workflows/review-release.yml index bbcfff1d6..b6645f0ee 100644 --- a/.github/workflows/pre-release.yml +++ b/.github/workflows/review-release.yml @@ -1,4 +1,4 @@ -name: SmallRye Pre Release +name: SmallRye Review Release on: pull_request: @@ -18,6 +18,12 @@ jobs: 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 + - uses: radcortez/milestone-review-action@main name: milestone review with: diff --git a/.github/workflows/update-milestone.yml b/.github/workflows/update-milestone.yml new file mode 100644 index 000000000..5a1f33549 --- /dev/null +++ b/.github/workflows/update-milestone.yml @@ -0,0 +1,17 @@ +name: Update Milestone + +on: + pull_request_target: + types: [closed] + +jobs: + update: + runs-on: ubuntu-latest + name: update-milestone + if: ${{github.event.pull_request.merged == true}} + + steps: + - uses: radcortez/milestone-set-action@main + name: milestone set + with: + github-token: ${{secrets.GITHUB_TOKEN}}