-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4 from sentrysoftware/feature/3-Update-github-rel…
…ease-and-project-site [#3] Update GitHub release and project site
- Loading branch information
Showing
7 changed files
with
460 additions
and
77 deletions.
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
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 |
---|---|---|
@@ -1,100 +1,195 @@ | ||
name: Build and Release | ||
# 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: | ||
release: | ||
types: [created] | ||
|
||
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 | ||
|
||
# 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: | ||
build-linux: | ||
prepare: | ||
name: Prepare Release v${{ inputs.releaseVersion }} | ||
|
||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v4 | ||
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' | ||
cache: 'maven' | ||
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: Build and Deploy from ubuntu-latest | ||
run: mvn -B deploy --file pom.xml -s $GITHUB_WORKSPACE/settings.xml | ||
- 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 \ | ||
release:clean \ | ||
release:prepare \ | ||
-DpreparationGoals="clean verify" \ | ||
-DreleaseVersion=${{ inputs.releaseVersion }} \ | ||
-DdevelopmentVersion=${{ inputs.developmentVersion }} \ | ||
-Dresume=false | ||
env: | ||
GITHUB_TOKEN: ${{ github.token }} | ||
|
||
build-windows: | ||
runs-on: windows-latest | ||
- name: Release rollback on failure | ||
run: | | ||
mvn -B -U \ | ||
release:rollback \ | ||
if: always() && (steps.prepare.outcome == 'failure') | ||
|
||
release: | ||
name: Release v${{ inputs.releaseVersion }} | ||
|
||
runs-on: ${{ matrix.os }} | ||
|
||
strategy: | ||
matrix: | ||
os: [ ubuntu-latest, windows-latest ] | ||
|
||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v4 | ||
|
||
- uses: actions/checkout@v4 | ||
|
||
- name: Set up JDK 17 | ||
uses: actions/setup-java@v4 | ||
with: | ||
java-version: '17' | ||
distribution: 'temurin' | ||
cache: 'maven' | ||
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: Build and Deplo from windows-latest | ||
run: mvn -B deploy --file pom.xml -s %GITHUB_WORKSPACE%/settings.xml | ||
- 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 }} \ | ||
env: | ||
GITHUB_TOKEN: ${{ github.token }} | ||
|
||
- name: Release rollback on failure | ||
run: | | ||
mvn -B -U \ | ||
release:rollback \ | ||
if: always() && (steps.perform.outcome == 'failure') | ||
|
||
release: | ||
needs: | ||
- build-linux | ||
- build-windows | ||
- uses: actions/upload-artifact@v4 | ||
with: | ||
name: jre-${{ matrix.os }} | ||
path: | | ||
./target/release/target/*.buildinfo | ||
./metricshub-jre-*/target/release/target/*.zip | ||
# Finalize job | ||
finalize: | ||
name: Finalize release | ||
runs-on: ubuntu-latest | ||
|
||
needs: [ prepare, release ] | ||
steps: | ||
|
||
- name: Get artifact version | ||
shell: bash | ||
run: | | ||
echo "artifact_version=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout)" >> $GITHUB_ENV | ||
- uses: actions/download-artifact@v4 | ||
with: | ||
merge-multiple: true | ||
|
||
- name: Set up Git | ||
run: | | ||
git config --global user.email "[email protected]" | ||
git config --global user.name "GitHub Actions" | ||
- name: Create Release | ||
id: create_release | ||
- 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-jre/target/* | ||
metricshub-windows-jre/target/* | ||
env: | ||
GITHUB_TOKEN: ${{ github.token }} | ||
*.buildinfo | ||
*.zip | ||
- name: Upload Release Linux Asset | ||
id: upload-release-linux-asset | ||
uses: actions/upload-release-asset@v1 | ||
env: | ||
GITHUB_TOKEN: ${{ github.token }} | ||
with: | ||
upload_url: ${{ github.event.release.upload_url }} | ||
asset_path: ./metricshub-jre-linux/target/metricshub-jre-linux-${{ env.artifact_version }}.zip | ||
asset_name: metricshub-jre-linux-${{ env.artifact_version }}.zip | ||
asset_content_type: application/zip | ||
|
||
- name: Upload Release Windows Asset | ||
id: upload-release-windows-asset | ||
uses: actions/upload-release-asset@v1 | ||
if: matrix.os == 'windows-latest' | ||
env: | ||
GITHUB_TOKEN: ${{ github.token }} | ||
- name: Create Pull Request from ${{ needs.prepare.outputs.branchName }} to ${{ github.event.repository.default_branch }} | ||
uses: devops-infra/[email protected] | ||
with: | ||
upload_url: ${{ github.event.release.upload_url }} | ||
asset_path: ./metricshub-jre-windows/target/metricshub-jre-windows-${{ env.artifact_version }}.zip | ||
asset_name: metricshub-jre-windows-${{ env.artifact_version }}.zip | ||
asset_content_type: application/zip | ||
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 |
Oops, something went wrong.