Update release workflows

This commit is contained in:
Janne Valkealahti
2021-04-23 13:53:49 +01:00
parent 18d1c793d4
commit 65f0b857bb
4 changed files with 321 additions and 0 deletions

28
.github/release-files-spec.json vendored Normal file
View File

@@ -0,0 +1,28 @@
{
"files": [
{
"aql": {
"items.find": {
"$and": [
{
"@build.name": "${buildname}",
"@build.number": "${buildnumber}",
"path": {"$match": "org*"}
},
{
"$or": [
{
"name": {"$match": "*.pom"}
},
{
"name": {"$match": "*.jar"}
}
]
}
]
}
},
"target": "nexus/"
}
]
}

144
.github/workflows/release-ga.yml vendored Normal file
View File

@@ -0,0 +1,144 @@
# 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
steps:
- uses: actions/checkout@v2
- uses: actions/setup-java@v1
with:
java-version: 1.8
- uses: jfrog/setup-jfrog-cli@v1
with:
version: 1.43.2
env:
JF_ARTIFACTORY_SPRING: ${{ secrets.JF_ARTIFACTORY_SPRING }}
# prepare env for cli to get a staging build working
- name: Configure JFrog Cli
run: |
jfrog rt 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-24x-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: |
jfrog rt gradle releaseVersion
echo PROJECT_VERSION=$(jfrog rt gradle "properties -q" | grep "version:" | awk '{print $2}') >> $GITHUB_ENV
# 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: |
jfrog rt gradle clean build artifactoryPublish
jfrog rt build-publish
# 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
# 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@v1
with:
version: 1.43.2
env:
JF_ARTIFACTORY_SPRING: ${{ secrets.JF_ARTIFACTORY_SPRING }}
# prepare env for cli to promote
- name: Configure JFrog Cli
run: |
jfrog rt 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-24x-release >> $GITHUB_ENV
echo JFROG_CLI_BUILD_NUMBER=$GITHUB_RUN_NUMBER >> $GITHUB_ENV
# promoting build from staging repo into release
- name: Promote Build
run: |
jfrog rt build-promote libs-release-local
# we've promoted so change repo to next dev version
- name: Switch to Next Dev Version
run: |
jfrog rt gradle nextVersion
- uses: jvalkeal/build-zoo-handler@v0.0.4
with:
commit-changes-branch: 2.4.x
commit-changes-message: Next development version
# 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: promote
environment: central
steps:
# need repo for spec file
- uses: actions/checkout@v2
- uses: jfrog/setup-jfrog-cli@v1
with:
version: 1.43.2
env:
JF_ARTIFACTORY_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-24x-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: |
jfrog 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_WITH_HEADER }}

94
.github/workflows/release-milestone.yml vendored Normal file
View File

@@ -0,0 +1,94 @@
# full release workflow which does a staging build, github tagging,
# promotion in artifactory
name: Release Milestone
on:
workflow_dispatch:
inputs:
milestone:
description: 'Milestone version like, M1 or RC1, etc'
required: true
# 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
steps:
- uses: actions/checkout@v2
- uses: actions/setup-java@v1
with:
java-version: 1.8
- uses: jfrog/setup-jfrog-cli@v1
with:
version: 1.43.2
env:
JF_ARTIFACTORY_SPRING: ${{ secrets.JF_ARTIFACTORY_SPRING }}
# prepare env for cli to get a staging build working
- name: Configure JFrog Cli
run: |
jfrog rt gradlec \
--use-wrapper \
--deploy-ivy-desc=false \
--server-id-resolve=repo.spring.io \
--server-id-deploy=repo.spring.io \
--repo-resolve=libs-milestone \
--repo-deploy=libs-staging-local
echo JFROG_CLI_BUILD_NAME=spring-statemachine-24x-milestone >> $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 Milestone Version
run: |
jfrog rt gradle milestoneVersion -PstatemachineMilestone=${{ github.event.inputs.milestone }}
echo PROJECT_VERSION=$(jfrog rt gradle "properties -q" | grep "version:" | awk '{print $2}') >> $GITHUB_ENV
# 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: |
jfrog rt gradle clean build artifactoryPublish
jfrog rt build-publish
# 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
# wait manual approval.
# promote build from staging to milestones
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@v1
with:
version: 1.43.2
env:
JF_ARTIFACTORY_SPRING: ${{ secrets.JF_ARTIFACTORY_SPRING }}
# prepare env for cli to promote
- name: Configure JFrog Cli
run: |
jfrog rt gradlec \
--use-wrapper \
--deploy-ivy-desc=false \
--server-id-resolve=repo.spring.io \
--server-id-deploy=repo.spring.io \
--repo-resolve=libs-milestone \
--repo-deploy=libs-staging-local
echo JFROG_CLI_BUILD_NAME=spring-statemachine-24x-milestone >> $GITHUB_ENV
echo JFROG_CLI_BUILD_NUMBER=$GITHUB_RUN_NUMBER >> $GITHUB_ENV
# promoting build from staging repo into release
- name: Promote Build
run: |
jfrog rt build-promote libs-milestone-local

View File

@@ -695,6 +695,61 @@ configure(rootProject) {
}
}
task nextVersion {
doLast{
def properties = new Properties()
def file = new File('gradle.properties')
properties.load(file.newDataInputStream())
def currentVersion = properties.getProperty('version')
if (currentVersion.indexOf('-SNAPSHOT') < 0) {
throw new GradleException('Version is a non SNAPSHOT version')
} else {
def (major, minor, patch) = version.tokenize('.')
patch = patch.replace('-SNAPSHOT', '')
patch = String.valueOf(patch.toInteger() + 1)
def nextVersion = major + '.' + minor + '.' + patch + '-SNAPSHOT'
properties.setProperty('version', nextVersion)
properties.store(file.newWriter(), null)
}
}
}
task milestoneVersion {
doLast{
def postfix = project.getProperty('statemachineMilestone')
if (!(postfix ==~ /(?:M|RC)\d+/)) {
throw new GradleException('Illegal milestone version')
}
def properties = new Properties()
def file = new File('gradle.properties')
properties.load(file.newDataInputStream())
def currentVersion = properties.getProperty('version')
if (currentVersion.indexOf('-SNAPSHOT') > 0) {
def nextVersion = currentVersion - '-SNAPSHOT' + '-' + postfix
properties.setProperty('version', nextVersion)
properties.store(file.newWriter(), null)
} else {
throw new GradleException('Version is not a SNAPSHOT version')
}
}
}
task releaseVersion {
doLast{
def properties = new Properties()
def file = new File('gradle.properties')
properties.load(file.newDataInputStream())
def currentVersion = properties.getProperty('version')
if (currentVersion.indexOf('-SNAPSHOT') > 0) {
def nextVersion = currentVersion - '-SNAPSHOT'
properties.setProperty('version', nextVersion)
properties.store(file.newWriter(), null)
} else {
throw new GradleException('Version is not a SNAPSHOT version')
}
}
}
artifacts {
archives docsZip
archives distZip