From e145588475a724fa7e7acf05f6a567ab00a56825 Mon Sep 17 00:00:00 2001 From: Janne Valkealahti Date: Tue, 18 Jan 2022 13:13:49 +0000 Subject: [PATCH] Add milestone release workflow --- .github/rlnotes.mustache | 25 +++++ .github/workflows/release-milestone.yml | 135 ++++++++++++++++++++++++ 2 files changed, 160 insertions(+) create mode 100644 .github/rlnotes.mustache create mode 100644 .github/workflows/release-milestone.yml diff --git a/.github/rlnotes.mustache b/.github/rlnotes.mustache new file mode 100644 index 00000000..17950a5f --- /dev/null +++ b/.github/rlnotes.mustache @@ -0,0 +1,25 @@ +{{#headerslength}} +# Generic Notes + +{{/headerslength}} + +{{#headers}} +**{{title}}** +{{body}} + +{{/headers}} +# Issues + +{{#issues}} +{{repo}}#{{number}} {{title}} +{{/issues}} + +{{#footerslength}} +# Additional Notes + +{{/footerslength}} +{{#footers}} +**{{title}}** +{{body}} + +{{/footers}} diff --git a/.github/workflows/release-milestone.yml b/.github/workflows/release-milestone.yml new file mode 100644 index 00000000..3a837a6e --- /dev/null +++ b/.github/workflows/release-milestone.yml @@ -0,0 +1,135 @@ +name: Release Milestone + +on: + workflow_dispatch: + inputs: + milestone: + description: 'Milestone version like, M1 or RC1, etc' + required: true + +jobs: + staging: + runs-on: ubuntu-latest + outputs: + project-version: ${{ steps.output.outputs.project-version }} + steps: + - uses: actions/checkout@v2 + - uses: actions/setup-java@v1 + with: + java-version: 1.8 + - uses: jvalkeal/setup-maven@v1 + with: + maven-version: 3.6.3 + - uses: jfrog/setup-jfrog-cli@v1 + with: + version: 1.46.4 + env: + JF_ARTIFACTORY_SPRING: ${{ secrets.JF_ARTIFACTORY_SPRING }} + - name: Configure JFrog Cli + run: | + jfrog rt mvnc \ + --server-id-deploy=repo.spring.io \ + --repo-deploy-releases=libs-staging-local \ + --repo-deploy-snapshots=libs-staging-local + echo JFROG_CLI_BUILD_NAME=spring-shell-main-milestone >> $GITHUB_ENV + echo JFROG_CLI_BUILD_NUMBER=$GITHUB_RUN_NUMBER >> $GITHUB_ENV + - name: Configure Milestone Version + run: | + jfrog rt mvn build-helper:parse-version versions:set \ + -DprocessAllModules=true \ + -DgenerateBackupPoms=false \ + -Dartifactory.publish.artifacts=false \ + -DnewVersion='${parsedVersion.majorVersion}.${parsedVersion.minorVersion}.${parsedVersion.incrementalVersion}-${{ github.event.inputs.milestone }}' \ + -B + echo PROJECT_VERSION=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout) >> $GITHUB_ENV + - name: Build and Publish + run: | + jfrog rt build-clean + jfrog rt mvn clean install \ + -DskipTests -U -B + jfrog rt build-publish + - name: Tag Release + uses: jvalkeal/build-zoo-handler@v0.0.4 + with: + tag-release-branch: ${{ env.PROJECT_VERSION }} + tag-release-tag: ${{ env.PROJECT_VERSION }} + tag-release-tag-prefix: v + - name: Output + id: output + env: + PROJECT_VERSION: ${{ env.PROJECT_VERSION }} + run: | + echo "::set-output name=project-version::$PROJECT_VERSION" + + promote: + runs-on: ubuntu-latest + needs: staging + environment: promote + steps: + - uses: actions/checkout@v2 + - uses: jfrog/setup-jfrog-cli@v1 + with: + version: 1.50.0 + env: + JF_ARTIFACTORY_SPRING: ${{ secrets.JF_ARTIFACTORY_SPRING }} + - name: Configure JFrog Cli + run: | + jfrog rt mvnc \ + --server-id-deploy=repo.spring.io \ + --repo-deploy-releases=libs-staging-local \ + --repo-deploy-snapshots=libs-staging-local + echo JFROG_CLI_BUILD_NAME=spring-shell-main-milestone >> $GITHUB_ENV + echo JFROG_CLI_BUILD_NUMBER=$GITHUB_RUN_NUMBER >> $GITHUB_ENV + - name: Promote Build + run: | + jfrog rt build-promote libs-milestone-local + + ghrelease: + runs-on: ubuntu-latest + needs: [staging, promote] + steps: + - uses: actions/checkout@v2 + - name: Install Tooling + run: | + curl -sSL https://github.com/cbroglie/mustache/releases/download/v1.2.2/mustache_1.2.2_linux_amd64.tar.gz | sudo tar -C /usr/local/bin/ --no-same-owner -xzv mustache + - name: GitHub Release + env: + PROJECT_VERSION: ${{needs.staging.outputs.project-version}} + GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}} + RELEASE_NOTES_FILE: ${{runner.temp}}/release_notes.md5 + RELEASE_NOTES_DATA: ${{runner.temp}}/release_notes_data.json + RELEASE_NOTES_HEADERS: ${{runner.temp}}/release_notes_headers.json + RELEASE_NOTES_FOOTERS: ${{runner.temp}}/release_notes_footers.json + RELEASE_NOTES_ISSUES: ${{runner.temp}}/release_notes_issues.json + run: | + gh issue list \ + --repo spring-projects/spring-shell \ + --search milestone:$PROJECT_VERSION \ + --label automation/rlnotes-header \ + --state all --json title,body \ + --jq '{headers:map(.),headerslength:(length)}' \ + > $RELEASE_NOTES_HEADERS + gh issue list \ + --repo spring-projects/spring-shell \ + --search milestone:$PROJECT_VERSION \ + --label automation/rlnotes-footer \ + --state all --json title,body \ + --jq '{footers:map(.),footerslength:(length)}' \ + > $RELEASE_NOTES_FOOTERS + gh issue list \ + --repo spring-projects/spring-shell \ + --search milestone:$PROJECT_VERSION \ + --state all --json number,title,labels \ + --jq '{issues:map(select((.labels | length == 0) or (any(.labels[].name; startswith("automation/rlnotes")|not))))}' \ + > $RELEASE_NOTES_ISSUES + jq -s '{issues:(.[0].issues),headers:(.[1].headers),headerslength:(.[1].headerslength),footers:(.[2].footers), footerslength:(.[2].footerslength)}' \ + $RELEASE_NOTES_ISSUES \ + $RELEASE_NOTES_HEADERS \ + $RELEASE_NOTES_FOOTERS \ + > $RELEASE_NOTES_DATA + mustache $RELEASE_NOTES_DATA .github/rlnotes.mustache > $RELEASE_NOTES_FILE + gh release create v$PROJECT_VERSION \ + --draft \ + --prerelease \ + --title "$PROJECT_VERSION" \ + --notes-file $RELEASE_NOTES_FILE