forked from TBD54566975/tbdex-rs
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Issue TBD54566975#97: Try a release workflow
- Loading branch information
1 parent
074cf3a
commit 99193d2
Showing
2 changed files
with
171 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,13 +4,14 @@ on: | |
workflow_dispatch: | ||
inputs: | ||
version: | ||
description: 'Version of Kotlin binary to publish to TBD Artifactory. For example "1.0.0-SNAPSHOT". If not supplied, will default to version specified in the POM. Must end in "-SNAPSHOT".' | ||
description: 'Version of Kotlin binary to publish to TBD Artifactory. For example "1.0.0-SNAPSHOT". If not supplied, will default to "commit-$shortSHA-SNAPSHOT" where $shortSHA is the shortform commit SHA. Must end in "-SNAPSHOT".' | ||
required: false | ||
default: "0.0.0-SNAPSHOT" | ||
push: | ||
branches: | ||
- main | ||
pull_request: | ||
workflow_call: | ||
|
||
env: | ||
CARGO_TERM_COLOR: always | ||
|
@@ -111,6 +112,14 @@ jobs: | |
distribution: "adopt" | ||
java-version: "11" | ||
|
||
# Cache Maven repo | ||
- uses: actions/cache@v3 | ||
with: | ||
path: ~/.m2/repository | ||
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }} | ||
restore-keys: | | ||
${{ runner.os }}-maven- | ||
- name: Resolve Snapshot Version | ||
id: resolve_version | ||
run: | | ||
|
@@ -134,6 +143,8 @@ jobs: | |
echo "Resolved SNAPSHOT Version: $resolvedVersion" | ||
echo "resolved_version=$resolvedVersion" >> $GITHUB_OUTPUT | ||
# Package up the native binaries | ||
#TODO Centralize this block as we re-use it via copy/paste right now | ||
- name: Download MacOS aarch64 Native Library | ||
uses: actions/[email protected] | ||
with: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,159 @@ | ||
name: CI | ||
|
||
on: | ||
workflow_dispatch: | ||
inputs: | ||
version: | ||
description: 'Version of tbDEX to release and publish to TBD Artifactory and Maven Central. For example "1.0.0". Required. Must not end in "-SNAPSHOT".' | ||
required: true | ||
|
||
jobs: | ||
|
||
run-ci: | ||
#TODO Update this to TBD org when done testing | ||
uses: ALRubinger/.tbdex-rs/workflows/ci.yml@main | ||
secrets: inherit | ||
|
||
git-tag: | ||
runs-on: ubuntu-latest | ||
|
||
name: Create Git Tag | ||
steps: | ||
|
||
- uses: actions/checkout@v4 | ||
with: | ||
submodules: true | ||
token: ${{ secrets.TBD_RELEASE_GITHUB_PERSONAL_ACCESS_TOKEN }} | ||
|
||
# Used in writing commits in the release process | ||
- name: Set Git Config | ||
run: | | ||
git config user.name "tbd-releases" | ||
git config user.email "[email protected]" | ||
# Cache Maven repo | ||
- uses: actions/cache@v3 | ||
with: | ||
path: ~/.m2/repository | ||
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }} | ||
restore-keys: | | ||
${{ runner.os }}-maven- | ||
- name: Set version of Kotlin and commit | ||
run: | | ||
# Get the required provided version | ||
version=${{ github.event.inputs.version }} | ||
# Precondition check; do not allow this to proceed if a version ending in "-SNAPSHOT" was specified | ||
if [[ $version =~ -SNAPSHOT$ ]]; then | ||
echo "Error: The version for release must not end with \"-SNAPSHOT\": $version" | ||
exit 1 | ||
fi | ||
# Get the existing version from the POM and set it to the nextVersion, keeping the POM effectively versionless | ||
nextVersion=$(grep -oPm1 "(?<=<version>)[^<]+" pom.xml) | ||
if [[ -z $nextVersion ]]; then | ||
echo "Error: Could not find a version in the pom.xml" | ||
exit 1 | ||
fi | ||
echo "Version to be released: $version" | ||
echo "Setting next development version back to original in pom.xml: $nextVersion" | ||
# cd into the Kotlin project | ||
cd bound/kt/ | ||
# Set newly resolved version in POM config | ||
mvn \ | ||
versions:set \ | ||
--batch-mode \ | ||
-DnewVersion=$version | ||
# Commit | ||
git add -Av | ||
git commit -m "[TBD Release Manager 🚀] Setting version to: $version" | ||
tagName = v$version | ||
git tag -a v$tagName -m "Tag version: v$tagName" # We tag with a prefix of "v" | ||
git push origin tag $tagName | ||
git push origin main | ||
# Make the version and tag name available to subsequent jobs as an output param | ||
echo "{RELEASE_TAG}={$tagName}" >> "$GITHUB_OUTPUT" | ||
echo "{RELEASE_VERSION}={$version}" >> "$GITHUB_OUTPUT" | ||
# Set the next development version and commit | ||
mvn \ | ||
versions:set \ | ||
--batch-mode \ | ||
-DnewVersion=$nextVersion | ||
git add -Av | ||
git commit -m "[TBD Release Manager 🚀] Setting next development version after $version to: $nextVersion" | ||
kotlin-release-to-tbd-artifactory: | ||
needs: git-tag | ||
runs-on: ubuntu-latest | ||
steps: | ||
|
||
# Check out the tag we created above | ||
- uses: actions/checkout@v4 | ||
with: | ||
submodules: true | ||
ref: ${{ steps.git-tag.outputs.RELEASE_TAG }} | ||
|
||
# Set up JDK | ||
- name: Set up JDK 11 | ||
uses: actions/setup-java@v3 | ||
with: | ||
distribution: "adopt" | ||
java-version: "11" | ||
# Cache Maven repo | ||
- uses: actions/cache@v3 | ||
with: | ||
path: ~/.m2/repository | ||
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }} | ||
restore-keys: | | ||
${{ runner.os }}-maven- | ||
# Package up the native binaries | ||
#TODO Centralize this block as we re-use it via copy/paste right now | ||
- name: Download MacOS aarch64 Native Library | ||
uses: actions/[email protected] | ||
with: | ||
name: aarch64-apple-darwin-dylib | ||
path: bound/kt/src/main/resources/ | ||
- name: Download MacOS x86_64 Native Library | ||
uses: actions/[email protected] | ||
with: | ||
name: x86_64-apple-darwin-dylib | ||
path: bound/kt/src/main/resources/ | ||
- name: Download Linux x86_64 GNU Native Library | ||
uses: actions/[email protected] | ||
with: | ||
name: x86_64-unknown-linux-gnu-so | ||
path: bound/kt/src/main/resources/ | ||
- name: Download Linux x86_64 MUSL Native Library | ||
uses: actions/[email protected] | ||
with: | ||
name: x86_64-unknown-linux-musl-so | ||
path: bound/kt/src/main/resources/ | ||
|
||
- name: Deploy Release Version of Kotlin Project to TBD Artifactory | ||
run: | | ||
# cd into the Kotlin project | ||
cd bound/kt/ | ||
# Only attempt to publish artifact if we have credentials | ||
if [ -n "${{ secrets.ARTIFACTORY_PASSWORD }}" ]; then | ||
# Maven deploy lifecycle will build, run tests, verify, sign, and deploy | ||
mvn deploy --batch-mode --settings .maven_settings.xml -P sign-artifacts | ||
else | ||
echo "Error: No credentials" | ||
exit 1 | ||
fi | ||
env: | ||
ARTIFACTORY_USERNAME: ${{ secrets.ARTIFACTORY_USERNAME }} | ||
ARTIFACTORY_PASSWORD: ${{ secrets.ARTIFACTORY_PASSWORD }} | ||
SIGN_KEY_PASS: ${{ secrets.GPG_SECRET_PASSPHRASE }} | ||
SIGN_KEY: ${{ secrets.GPG_SECRET_KEY }} | ||
|
||
|
||
|