Draft Release #86
Workflow file for this run
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
name: Draft Release | |
on: | |
workflow_dispatch: | |
push: | |
branches: [ main ] | |
# By setting up concurrency group using github.ref, we essentially instruct github to only run one workflow at a time per branch | |
# With "cancel-in-progress: true" we also specify that existing/running workflows for that branch will be canceled | |
concurrency: | |
group: Release-${{github.ref}} | |
cancel-in-progress: true | |
jobs: | |
releaseJavaBinary: | |
name: Release Java Binary | |
runs-on: ubuntu-latest | |
steps: | |
- name: Setup Environment | |
shell: bash | |
run: | | |
echo "MVN_OPTS=-Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=WARN -Dorg.slf4j.simpleLogger.showDateTime=true -Djava.awt.headless=true --batch-mode --fail-at-end --show-version -DinstallAtEnd=true -DdeployAtEnd=true" >> $GITHUB_ENV | |
- name: Fetch Sources | |
uses: actions/checkout@v4 | |
- name: Setup Environment | |
run: | | |
VERSION=$(./mvnw help:evaluate -Dexpression=project.version -q -DforceStdout) | |
echo "VERSION=$VERSION" >> $GITHUB_ENV | |
- name: Setup Java | |
uses: actions/setup-java@v4 | |
with: | |
distribution: corretto | |
java-version: 17 | |
- name: Build Java Executable | |
run: ./mvnw package $MVN_OPTS | |
- name: Remove Old Draft Releases | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
run: | | |
gh api repos/{owner}/{repo}/releases \ | |
--jq '.[] | select(.draft == true) | .id' \ | |
| xargs -I '{}' gh api -X DELETE repos/{owner}/{repo}/releases/{} | |
# Create new release draft - which is not publicly visible and requires manual acceptance | |
- name: Create Draft Release | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
run: | | |
mv ./target/radicle-migration-tool-${{ env.VERSION }}-runner.jar \ | |
./target/radicle-migration-tool-${{ env.VERSION }}.jar | |
gh release create v${{ env.VERSION }} ./target/radicle-migration-tool-${{ env.VERSION }}.jar \ | |
--draft \ | |
--title "v${{ env.VERSION }}" \ | |
--generate-notes | |
releaseDockerImage: | |
name: Release Docker Image | |
runs-on: ubuntu-latest | |
steps: | |
- name: Fetch Sources | |
uses: actions/checkout@v4 | |
- name: Setup Environment | |
run: | | |
VERSION=$(./mvnw help:evaluate -Dexpression=project.version -q -DforceStdout) | |
echo "VERSION=$VERSION" >> $GITHUB_ENV | |
echo "MVN_OPTS=-Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=WARN -Dorg.slf4j.simpleLogger.showDateTime=true -Djava.awt.headless=true --batch-mode --fail-at-end --show-version -DinstallAtEnd=true -DdeployAtEnd=true" >> $GITHUB_ENV | |
- name: Setup Java | |
uses: actions/setup-java@v4 | |
with: | |
distribution: corretto | |
java-version: 17 | |
# Create the docker image | |
- name: Build & Push Docker Image | |
if: success() | |
env: | |
IMAGE_NAME: ${{ github.repository }} | |
IMAGE_VERSION: ${{ env.VERSION }} | |
REGISTRY_PASS: ${{ secrets.GITHUB_TOKEN }} | |
REGISTRY_USER: ${{ github.actor }} | |
REGISTRY_NAME: ghcr.io | |
run: | | |
set -x | |
echo $REGISTRY_PASS | docker login "${REGISTRY_NAME}" -u "${REGISTRY_PASS}" --password-stdin | |
# Changing the default driver is mandatory for multi-arch builds | |
docker buildx create --name multiarch --use | |
./mvnw package -Pdocker -DdockerImageTag=draft -DdockerImageArchs=linux/amd64,linux/arm64 -DdockerBuildOutput=type=image \ | |
-DdockerImagePush=true -DdockerRegistry="${REGISTRY_NAME}" -DdockerPassword="${REGISTRY_PASS}" -DdockerUsername="${REGISTRY_USER}" $MVN_OPTS | |
releaseNativeBinaries: | |
needs: releaseJavaBinary | |
name: Release Native Binary | |
runs-on: ${{ matrix.os }} | |
strategy: | |
matrix: | |
os: [ubuntu-latest, macos-latest] | |
steps: | |
- name: Fetch Sources | |
uses: actions/checkout@v4 | |
- name: Setup Java | |
uses: actions/setup-java@v4 | |
with: | |
distribution: corretto | |
java-version: 17 | |
- name: Setup Environment | |
shell: bash | |
run: | | |
echo "MVN_OPTS=-Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=WARN -Dorg.slf4j.simpleLogger.showDateTime=true -Djava.awt.headless=true -Dio.netty.tryReflectionSetAccessible=true --batch-mode --fail-at-end --show-version -DinstallAtEnd=true -DdeployAtEnd=true" >> $GITHUB_ENV | |
MAVEN_COMMAND="$(if [ "$RUNNER_OS" == "Windows" ]; then echo "./mvnw.cmd"; else echo "./mvnw"; fi)" | |
VERSION=$(eval "$MAVEN_COMMAND help:evaluate -Dexpression=project.version -q -DforceStdout") | |
ASSET_SUFFIX="$(if [ "$RUNNER_OS" == "Windows" ]; then echo ".exe"; else echo ""; fi)" | |
echo "VERSION=$VERSION" >> $GITHUB_ENV | |
echo "MAVEN_COMMAND=$MAVEN_COMMAND" >> $GITHUB_ENV | |
echo "ASSET_SUFFIX=$ASSET_SUFFIX" >> $GITHUB_ENV | |
- name: Setup GraalVM | |
if: startsWith(matrix.os, 'macos-') || startsWith(matrix.os, 'windows-') | |
uses: graalvm/setup-graalvm@v1 | |
with: | |
version: 'latest' | |
gds-token: ${{ secrets.GDS_TOKEN }} | |
java-version: '17' | |
components: 'native-image' | |
github-token: ${{ secrets.GITHUB_TOKEN }} | |
- name: Build Native Executable | |
shell: bash | |
run: eval "${MAVEN_COMMAND} verify -Pnative $MVN_OPTS" | |
- name: Upload Native Executable To Draft Release | |
shell: bash | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
run: | | |
mv ./target/radicle-migration-tool-${{ env.VERSION }}-runner${{ env.ASSET_SUFFIX }} \ | |
./target/radicle-migration-tool-${{ env.VERSION }}-${{ matrix.os }}${{ env.ASSET_SUFFIX }} | |
gh release upload v${{ env.VERSION }} \ | |
./target/radicle-migration-tool-${{ env.VERSION }}-${{ matrix.os }}${{ env.ASSET_SUFFIX }} \ | |
--clobber |