Release MetricsHub v0.9.02 #2
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: Release | |
run-name: Release MetricsHub v${{ inputs.releaseVersion }} | |
on: | |
workflow_dispatch: | |
inputs: | |
releaseVersion: | |
type: string | |
description: "Release version" | |
required: true | |
default: "" | |
developmentVersion: | |
type: string | |
description: "New SNAPSHOT version" | |
required: true | |
default: "" | |
autoRelease: | |
type: boolean | |
description: "Release staging repository immediately?" | |
required: false | |
default: false | |
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 21 | |
uses: actions/setup-java@v4 | |
with: | |
java-version: '21' | |
distribution: 'temurin' | |
cache: 'maven' | |
- 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: Update project version to ${{ inputs.releaseVersion }} | |
run: | | |
mvn versions:set -DnewVersion=${{ inputs.releaseVersion }} | |
mvn versions:commit | |
- name: Commit ${{ inputs.releaseVersion }} | |
run: | | |
git add pom.xml metricshub-*/pom.xml | |
git commit -m "Updated POM version to ${{ inputs.releaseVersion }}" | |
- name: Create tag ${{ env.tagName }} | |
run: | | |
git tag -a ${{ env.tagName }} -m "Release ${{ env.tagName }}" | |
- name: Push tag ${{ env.tagName }} | |
run: | | |
git push origin ${{ env.tagName }} | |
- name: Prepare next version ${{ inputs.developmentVersion }} | |
run: | | |
mvn versions:set -DnewVersion=${{ inputs.developmentVersion }} | |
mvn versions:commit | |
git add pom.xml metricshub-*/pom.xml | |
git commit -m "Updated POM version to ${{ inputs.developmentVersion }}" | |
- name: Push next version ${{ inputs.developmentVersion }}" | |
run: | | |
git push origin ${{ env.branchName }} | |
release: | |
name: Release v${{ inputs.releaseVersion }} on ${{ matrix.os }} | |
needs: prepare | |
runs-on: ${{ matrix.os }} | |
strategy: | |
matrix: | |
os: [ ubuntu-latest, windows-latest ] | |
steps: | |
- name: Setup GitHub Pages | |
id: pages | |
uses: actions/configure-pages@v4 | |
with: | |
enablement: true | |
- uses: actions/checkout@v4 | |
- name: Set up JDK 21 | |
uses: actions/setup-java@v4 | |
with: | |
java-version: '21' | |
distribution: 'temurin' | |
cache: 'maven' | |
gpg-private-key: ${{ secrets.MAVEN_GPG_PRIVATE_KEY }} | |
- name: Set up Maven settings.xml on ${{ matrix.os }} | |
uses: s4u/[email protected] | |
with: | |
repositories: '[{"id":"github","name":"MetricsHub JRE Builder","url":"https://maven.pkg.github.com/sentrysoftware/metricshub-jre-builder","snapshots":{"enabled":true},"releases":{"enabled":true}}]' | |
servers: '[{"id": "ossrh", "username": "${env.OSSRH_USERNAME}", "password": "${env.OSSRH_TOKEN}"}, {"id": "gpg.passphrase", "passphrase": "${env.MAVEN_GPG_PASSPHRASE}", "configuration": {}}]' | |
sonatypeSnapshots: true | |
- name: Checkout ${{ needs.prepare.outputs.tagName }} branch | |
run: | | |
git fetch | |
git checkout ${{ needs.prepare.outputs.tagName }} 2>/dev/null | |
- name: Perform MetricsHub Artifacts release to Maven Central | |
run: | | |
mvn -B -U -Prelease deploy --file pom.xml \ | |
-Dgpg.passphraseServerId=gpg.passphrase \ | |
-Darguments=-Dgpg.passphraseServerId=gpg.passphrase | |
env: | |
GITHUB_TOKEN: ${{ github.token }} | |
AUTO_RELEASE_AFTER_CLOSE: ${{ inputs.autoRelease }} | |
MAVEN_GPG_PASSPHRASE: ${{ secrets.MAVEN_GPG_PASSPHRASE }} | |
OSSRH_USERNAME: ${{ secrets.OSSRH_USERNAME }} | |
OSSRH_TOKEN: ${{ secrets.OSSRH_TOKEN }} | |
- name: Upload Maven Site to GitHub Pages | |
uses: actions/upload-pages-artifact@v3 | |
if: ${{ matrix.os == 'ubuntu-latest' }} | |
with: | |
path: ./metricshub-doc/target/site | |
- name: Upload Linux Artifact | |
uses: actions/upload-artifact@v4 | |
if: ${{ matrix.os == 'ubuntu-latest' }} | |
with: | |
name: metricshub-linux-package-${{ inputs.releaseVersion }} | |
path: | | |
./metricshub-linux/target/metricshub-linux-${{ inputs.releaseVersion }}.tar.gz | |
./metricshub-linux/target/metricshub-linux-${{ inputs.releaseVersion }}.buildinfo | |
- name: Upload Windows Artifact | |
uses: actions/upload-artifact@v4 | |
if: ${{ matrix.os == 'windows-latest' }} | |
with: | |
name: metricshub-windows-package-${{ inputs.releaseVersion }} | |
path: | | |
./metricshub-windows/target/metricshub-windows-${{ inputs.releaseVersion }}.zip | |
./metricshub-windows/target/metricshub-windows-${{ inputs.releaseVersion }}.buildinfo | |
- name: Upload Site Artifact | |
uses: actions/upload-artifact@v4 | |
if: ${{ matrix.os == 'ubuntu-latest' }} | |
with: | |
name: metricshub-site-${{ inputs.releaseVersion }} | |
path: | | |
./metricshub-doc/target/metricshub-doc-${{ inputs.releaseVersion }}-site.jar | |
./metricshub-doc/target/metricshub-doc-${{ inputs.releaseVersion }}.buildinfo | |
- name: Upload Docker Artifact | |
uses: actions/upload-artifact@v4 | |
if: ${{ matrix.os == 'ubuntu-latest' }} | |
with: | |
name: metricshub-docker-package-${{ inputs.releaseVersion }} | |
path: ./metricshub-linux/target/metricshub-linux-${{ inputs.releaseVersion }}-docker.tar.gz | |
- name: Summary with staging repositories and buildinfo | |
id: stagingList | |
run: | | |
echo "# Staging Repositories" >> $GITHUB_STEP_SUMMARY | |
echo "\`\`\`" >> $GITHUB_STEP_SUMMARY | |
mvn -B -U \ | |
-Prelease \ | |
org.sonatype.plugins:nexus-staging-maven-plugin:rc-list >> $GITHUB_STEP_SUMMARY | |
echo "\`\`\`" >> $GITHUB_STEP_SUMMARY | |
echo "# Buildinfo" >> $GITHUB_STEP_SUMMARY | |
echo "\`\`\`" >> $GITHUB_STEP_SUMMARY | |
cat target/*.buildinfo >> $GITHUB_STEP_SUMMARY | |
echo "\`\`\`" >> $GITHUB_STEP_SUMMARY | |
env: | |
OSSRH_USERNAME: ${{ secrets.OSSRH_USERNAME }} | |
OSSRH_TOKEN: ${{ secrets.OSSRH_TOKEN }} | |
# Deployment job | |
deploy: | |
name: Deploy GitHub Pages | |
environment: | |
name: github-pages | |
url: ${{ steps.deployment.outputs.page_url }} | |
runs-on: ubuntu-latest | |
needs: release | |
steps: | |
- name: Deploy to GitHub Pages | |
id: deployment | |
uses: actions/deploy-pages@v4 | |
# Finalize job | |
finalize: | |
name: Finalize release | |
runs-on: ubuntu-latest | |
needs: [ prepare, release, deploy ] | |
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: | | |
metricshub-linux-${{ inputs.releaseVersion }}-docker.tar.gz | |
metricshub-doc-${{ inputs.releaseVersion }}-site.jar | |
metricshub-doc-${{ inputs.releaseVersion }}.buildinfo | |
metricshub-windows-${{ inputs.releaseVersion }}.zip | |
metricshub-windows-${{ inputs.releaseVersion }}.buildinfo | |
metricshub-linux-${{ inputs.releaseVersion }}.buildinfo | |
metricshub-linux-${{ inputs.releaseVersion }}.tar.gz | |
- 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 |