# full release workflow which does a staging build, github tagging, # promotion in artifactory and release into central. name: Release GA on: workflow_dispatch: # there's 3 jobs, staging, promote and central. # promote waits staging and manual approval and # central waits promote and manual approval. jobs: # build and release to staging repo. # stash artifactory build id so that promote and central # jobs can work on it. 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: 17 - uses: jfrog/setup-jfrog-cli@v3 with: version: 2.39.1 env: JF_ENV_SPRING: ${{ secrets.JF_ARTIFACTORY_SPRING }} # prepare env for cli to get a staging build working - name: Configure JFrog Cli run: | jf gradlec \ --use-wrapper \ --deploy-ivy-desc=false \ --server-id-resolve=repo.spring.io \ --server-id-deploy=repo.spring.io \ --repo-resolve=libs-release \ --repo-deploy=libs-staging-local echo JFROG_CLI_BUILD_NAME=spring-statemachine-main-release >> $GITHUB_ENV echo JFROG_CLI_BUILD_NUMBER=$GITHUB_RUN_NUMBER >> $GITHUB_ENV # switch from snapshot to a release version and extract project # version to get used with tagging - name: Configure Release Version run: | jf gradle releaseVersion echo PROJECT_VERSION=$(cat gradle.properties | grep "version=" | awk -F'=' '{print $2}') >> $GITHUB_ENV env: GRADLE_ENTERPRISE_CACHE_USERNAME: ${{ secrets.GRADLE_ENTERPRISE_CACHE_USER }} GRADLE_ENTERPRISE_CACHE_PASSWORD: ${{ secrets.GRADLE_ENTERPRISE_CACHE_PASSWORD }} GRADLE_ENTERPRISE_ACCESS_KEY: ${{ secrets.GRADLE_ENTERPRISE_SECRET_ACCESS_KEY }} # build and publish to staging repo. # we've allready tested with snapshots so no need to test # with a release build as we are not a release train. - name: Build and Publish run: | jf gradle clean build artifactoryPublish jf rt build-publish env: GRADLE_ENTERPRISE_CACHE_USERNAME: ${{ secrets.GRADLE_ENTERPRISE_CACHE_USER }} GRADLE_ENTERPRISE_CACHE_PASSWORD: ${{ secrets.GRADLE_ENTERPRISE_CACHE_PASSWORD }} GRADLE_ENTERPRISE_ACCESS_KEY: ${{ secrets.GRADLE_ENTERPRISE_SECRET_ACCESS_KEY }} # we've now done a release build, branch and tag it in github - 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" # wait manual approval. # promote build from staging to releases promote: runs-on: ubuntu-latest needs: staging environment: promote steps: # need repo to push release branch and a tag - uses: actions/checkout@v2 - uses: jfrog/setup-jfrog-cli@v3 with: version: 2.39.1 env: JF_ENV_SPRING: ${{ secrets.JF_ARTIFACTORY_SPRING }} # prepare env for cli to promote - name: Configure JFrog Cli run: | jf gradlec \ --use-wrapper \ --deploy-ivy-desc=false \ --server-id-resolve=repo.spring.io \ --server-id-deploy=repo.spring.io \ --repo-resolve=libs-release \ --repo-deploy=libs-staging-local echo JFROG_CLI_BUILD_NAME=spring-statemachine-main-release >> $GITHUB_ENV echo JFROG_CLI_BUILD_NUMBER=$GITHUB_RUN_NUMBER >> $GITHUB_ENV # promoting build from staging repo into release - name: Promote Build run: | jf rt build-promote libs-release-local # we've promoted so change repo to next dev version - name: Switch to Next Dev Version run: | jf gradle nextVersion env: GRADLE_ENTERPRISE_CACHE_USERNAME: ${{ secrets.GRADLE_ENTERPRISE_CACHE_USER }} GRADLE_ENTERPRISE_CACHE_PASSWORD: ${{ secrets.GRADLE_ENTERPRISE_CACHE_PASSWORD }} GRADLE_ENTERPRISE_ACCESS_KEY: ${{ secrets.GRADLE_ENTERPRISE_SECRET_ACCESS_KEY }} - uses: jvalkeal/build-zoo-handler@v0.0.4 with: commit-changes-branch: main commit-changes-message: Next development version # gh release before central 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-statemachine \ --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-statemachine \ --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-statemachine \ --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 \ --title "$PROJECT_VERSION" \ --notes-file $RELEASE_NOTES_FILE # wait manual approval. # pull released artifacts from repo and do a dance with central sync where we # create checksum and signature files, create staging repo and upload # files into it, and then finally close and release that repo. central: runs-on: ubuntu-latest needs: ghrelease environment: central steps: # need repo for spec file - uses: actions/checkout@v2 - uses: jfrog/setup-jfrog-cli@v3 with: version: 2.39.1 env: JF_ENV_SPRING: ${{ secrets.JF_ARTIFACTORY_SPRING }} # prepare env for cli do download released files - name: Configure JFrog Cli run: | echo JFROG_CLI_BUILD_NAME=spring-statemachine-main-release >> $GITHUB_ENV echo JFROG_CLI_BUILD_NUMBER=$GITHUB_RUN_NUMBER >> $GITHUB_ENV # download released files for a build. # spec file defines files we actually need for central # as release in artifactory contains some test and samples modules # which we don't want in central. - name: Download Release Files run: | jf rt download \ --spec .github/release-files-spec.json \ --spec-vars "buildname=$JFROG_CLI_BUILD_NAME;buildnumber=$JFROG_CLI_BUILD_NUMBER" # last step, sync to central. - uses: jvalkeal/nexus-sync@v0 with: url: ${{ secrets.OSSRH_URL }} username: ${{ secrets.OSSRH_S01_TOKEN_USERNAME }} password: ${{ secrets.OSSRH_S01_TOKEN_PASSWORD }} staging-profile-name: ${{ secrets.OSSRH_STAGING_PROFILE_NAME }} create: true upload: true close: true release: true generate-checksums: true pgp-sign: true pgp-sign-passphrase: ${{ secrets.GPG_PASSPHRASE }} pgp-sign-private-key: ${{ secrets.GPG_PRIVATE_KEY }}