Skip to content

Release v1.0.00 to GitHub Packages #52

Release v1.0.00 to GitHub Packages

Release v1.0.00 to GitHub Packages #52

Workflow file for this run

# Fully automated release to GitHub Packages
# This workflow performs the following operations:
#
# - Create a release branch
# - Prepare the release with Maven
# - Perform the release to GitHub Packages
# - Upload Maven Site to GitHub Pages
# - Publish the packages as a GitHub Release
# - Create a Pull Request to prepare next development version
#
# Requires the GITHUB_TOKEN secret to be defined (workspace or organization)
name: Release to GitHub Packages
run-name: Release v${{ inputs.releaseVersion }} to GitHub Packages
on:
workflow_dispatch:
inputs:
releaseVersion:
type: string
description: "Release version"
required: true
default: ""
developmentVersion:
type: string
description: "New SNAPSHOT version"
required: true
default: ""
permissions:
contents: write
pull-requests: write
pages: write
id-token: write
packages: write
# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued.
# However, do NOT cancel in-progress runs as we want to allow these releases and deployments to complete.
concurrency:
group: release
cancel-in-progress: false
# Default to bash
defaults:
run:
shell: bash
jobs:
prepare:
name: Prepare Release v${{ inputs.releaseVersion }}
runs-on: ubuntu-latest
outputs:
branchName: ${{ env.branchName }}
tagName: ${{ env.tagName }}
steps:
- uses: actions/checkout@v4
- name: Set up JDK 17
uses: actions/setup-java@v4
with:
java-version: "17"
distribution: temurin
java-package: jdk
cache: maven
server-id: github # Value of the distributionManagement/repository/id field of the pom.xml
settings-path: ${{ github.workspace }} # location for the settings.xml file
- name: Configure Git User
run: |
git config user.email "[email protected]"
git config user.name "GitHub Actions"
- name: Set release branch and tag name
run: |
echo "branchName=release/v$INPUT_RELEASEVERSION" >> $GITHUB_ENV
echo "tagName=v$INPUT_RELEASEVERSION" >> $GITHUB_ENV
env:
INPUT_RELEASEVERSION: ${{ inputs.releaseVersion }}
- name: Create ${{ env.branchName }} branch
run: |
git checkout ${{ env.branchName }} 2>/dev/null || git checkout -b ${{ env.branchName }}
git push --force origin ${{ env.branchName }}
- name: Clean up existing ${{ env.tagName }} tags
run: |
git tag -d ${{ env.tagName }} || true
git push origin :refs/tags/${{ env.tagName }} || true
- name: Prepare release
id: prepare
run: |
mvn -B -U \
-Prelease
release:clean \
release:prepare \
-DpreparationGoals="clean verify" \
-DreleaseVersion=${{ inputs.releaseVersion }} \
-DdevelopmentVersion=${{ inputs.developmentVersion }} \
-Dresume=false
env:
GITHUB_TOKEN: ${{ github.token }}
- name: Release rollback on failure
run: |
mvn -B -U \
release:rollback \
if: always() && (steps.prepare.outcome == 'failure')
- uses: actions/upload-artifact@v4
with:
name: release-${{ matrix.os }}.properties
path: release.properties
release:
name: Release v${{ inputs.releaseVersion }} on ${{ matrix.os }}
needs: prepare
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ ubuntu-latest, windows-latest ]
steps:
- uses: actions/checkout@v4
- name: Set up JDK 17
uses: actions/setup-java@v4
with:
java-version: "17"
distribution: temurin
java-package: jdk
cache: maven
server-id: github # Value of the distributionManagement/repository/id field of the pom.xml
settings-path: ${{ github.workspace }} # location for the settings.xml file
- uses: actions/download-artifact@v4
with:
name: release-${{ matrix.os }}.properties
- name: Perform release to GitHub Packages
id: perform
run: |
mvn -B -U \
release:perform \
-Dgoals=deploy \
-DworkingDirectory=$GITHUB_WORKSPACE/target/release \
-DreleaseVersion=${{ inputs.releaseVersion }} \
-DdevelopmentVersion=${{ inputs.developmentVersion }} \
-s $GITHUB_WORKSPACE/settings.xml
env:
GITHUB_TOKEN: ${{ github.token }}
- name: Release rollback on failure
run: |
mvn -B -U \
release:rollback \
if: always() && (steps.perform.outcome == 'failure')
- uses: actions/upload-artifact@v4
with:
name: jre-${{ matrix.os }}
path: |
./target/release/target/*.buildinfo
./target/release/metricshub-jre-*/target/*.zip
./target/release/metricshub-jre-*/target/*.buildinfo
# Finalize job
finalize:
name: Finalize release
runs-on: ubuntu-latest
needs: [ prepare, release ]
steps:
- uses: actions/checkout@v4
- uses: actions/download-artifact@v4
with:
merge-multiple: true
- name: Create a GitHub Release
uses: softprops/action-gh-release@v1
with:
tag_name: ${{ needs.prepare.outputs.tagName }}
fail_on_unmatched_files: false
generate_release_notes: true
files: |
./target/*.buildinfo
./metricshub-jre-*/target/*.zip
./metricshub-jre-*/target/*.buildinfo
- name: Create Pull Request from ${{ needs.prepare.outputs.branchName }} to ${{ github.event.repository.default_branch }}
uses: devops-infra/[email protected]
with:
github_token: ${{ github.token }}
source_branch: ${{ needs.prepare.outputs.branchName }}
target_branch: ${{ github.event.repository.default_branch }}
title: Release v${{ inputs.releaseVersion }} and prepare v${{ inputs.developmentVersion }}
body: |
## Automated release
* Release **v${{ inputs.releaseVersion }}**
* Prepare **v${{ inputs.developmentVersion }}**
label: automatic
get_diff: true
allow_no_diff: true