Release #133
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 | |
on: | |
workflow_dispatch: | |
inputs: | |
version: | |
description: Override deployment version | |
default: "" | |
type: string | |
skip-maven-release: | |
description: Skip Maven release steps | |
default: false | |
type: boolean | |
skip-tests: | |
description: Skip tests | |
default: false | |
type: boolean | |
skip-nexus-promotion: | |
description: Skip Nexus promotion steps | |
default: false | |
type: boolean | |
skip-pages: | |
description: Skip pages | |
default: false | |
type: boolean | |
jobs: | |
deploy: | |
name: Deploy | |
runs-on: ubuntu-latest | |
permissions: | |
contents: write | |
id-token: write | |
pages: write | |
environment: | |
name: maven-central | |
url: https://repo1.maven.org/maven2/io/github/ascopes/protobuf-maven-plugin | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Set up JDK | |
uses: actions/setup-java@v4 | |
with: | |
java-version: 23 | |
distribution: temurin | |
server-id: ossrh | |
server-username: OSSRH_USERNAME | |
server-password: OSSRH_TOKEN | |
gpg-passphrase: GPG_PASSPHRASE | |
gpg-private-key: ${{ secrets.GPG_PRIVATE_KEY }} | |
- name: Configure Git | |
run: |- | |
git config user.name '${{ github.actor }}' | |
git config user.email '${{ github.actor }}@users.noreply.github.com' | |
- name: Install protoc to $PATH | |
run: scripts/install-protoc-to-github-runner.sh | |
- name: Determine release version details | |
run: |- | |
group_id="$(./mvnw help:evaluate -q -DforceStdout -Dexpression="project.groupId")" | |
echo "group_id=${group_id}" >> "${GITHUB_ENV}" | |
artifact_id="$(./mvnw help:evaluate -q -DforceStdout -Dexpression="project.artifactId")" | |
echo "artifact_id=${artifact_id}" >> "${GITHUB_ENV}" | |
if [[ '${{ inputs.version }}' == "" ]]; then | |
echo "No explicit version provided, calculating next non-snapshot build from POM" | |
release_version="$(./mvnw -B help:evaluate -Dexpression=project.version -q -DforceStdout | sed 's/-SNAPSHOT//g')" | |
else | |
release_version='${{ inputs.version }}' | |
fi | |
echo "release_version=${release_version}" >> "${GITHUB_ENV}" | |
- name: Build and test | |
if: ${{ ! inputs.skip-tests }} | |
run: ./mvnw -B -e clean verify | |
- name: Deploy staging to Nexus | |
if: ${{ ! inputs.skip-maven-release }} | |
run: |- | |
./mvnw -B -e \ | |
-Dpassword='${{ secrets.GITHUB_TOKEN }}' \ | |
-DreleaseVersion="${release_version}" \ | |
-DsignTag=false \ | |
-Dtag="v${release_version}" \ | |
release:prepare release:perform | |
env: | |
OSSRH_USERNAME: ${{ secrets.OSSRH_USERNAME }} | |
OSSRH_TOKEN: ${{ secrets.OSSRH_TOKEN }} | |
GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }} | |
- name: Promote staging to Maven Central | |
if: ${{ ! inputs.skip-nexus-promotion }} | |
run: |- | |
./scripts/close-nexus-repos.sh \ | |
-u "${OSSRH_USERNAME}" \ | |
-p "${OSSRH_TOKEN}" \ | |
-g "${group_id}" \ | |
-a "${artifact_id}" \ | |
-v "${release_version}" \ | |
-s "https://s01.oss.sonatype.org/" | |
env: | |
OSSRH_USERNAME: ${{ secrets.OSSRH_USERNAME }} | |
OSSRH_TOKEN: ${{ secrets.OSSRH_TOKEN }} | |
- name: Abort and rollback staging release | |
if: ${{ failure() && ! inputs.skip-maven-release }} | |
run: |- | |
./mvnw -B -e \ | |
-Dpassword='${{ secrets.GITHUB_TOKEN }}' \ | |
-DreleaseVersion="${release_version}" \ | |
-Dtag="v${release_version}" \ | |
release:rollback | |
env: | |
OSSRH_USERNAME: ${{ secrets.OSSRH_USERNAME }} | |
OSSRH_TOKEN: ${{ secrets.OSSRH_TOKEN }} | |
GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }} | |
- name: Create GitHub release | |
uses: ncipollo/release-action@v1 | |
if: ${{ ! inputs.skip-nexus-promotion }} | |
with: | |
tag: v${{ env.release_version }} | |
name: v${{ env.release_version }} | |
generateReleaseNotes: true | |
token: ${{ secrets.GITHUB_TOKEN }} | |
- name: Generate pages | |
if: ${{ ! inputs.skip-pages }} | |
run: |- | |
./mvnw -B versions:set -DnewVersion="${release_version}" | |
./mvnw site -B -e -DskipTests -Dinvoker.skip | |
- name: Upload pages | |
if: ${{ ! inputs.skip-pages }} | |
uses: actions/upload-pages-artifact@v3 | |
with: | |
path: protobuf-maven-plugin/target/site | |
- name: Deploy pages | |
if: ${{ ! inputs.skip-pages }} | |
uses: actions/deploy-pages@v4 | |
- name: Upload build logs as artifacts | |
uses: actions/upload-artifact@v4 | |
if: always() | |
with: | |
name: jdk-${{ matrix.java-version }}-logs | |
path: |- | |
**/build.log | |
**/maven-status/** | |
**/surefire-reports/**.txt | |
compression-level: 9 | |
retention-days: 90 # Max allowed | |
include-hidden-files: true | |
if-no-files-found: error |