Release #1
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: Deploy | |
on: | |
workflow_dispatch: | |
inputs: | |
dry-run: | |
description: "Run the steps without deploying anything" | |
default: false | |
type: boolean | |
version: | |
description: "Override deployment version" | |
default: "" | |
type: string | |
jobs: | |
deploy: | |
name: Deploy to Maven Central | |
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 11 | |
uses: actions/setup-java@v3 | |
with: | |
java-version: '11' | |
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: 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: Configure Git | |
run: |- | |
git config user.name '${{ github.actor }}' | |
git config user.email '${{ github.actor }}@users.noreply.github.com' | |
- name: Perform release to staging | |
run: |- | |
./mvnw -B -e \ | |
-DdryRun='${{ inputs.dry-run }}' \ | |
-Dpassword='${{ secrets.GITHUB_TOKEN }}' \ | |
-DreleaseVersion="${release_version}" \ | |
-DsignTag=false \ | |
-Dtag="v${release_version}" \ | |
clean verify site release:prepare release:perform | |
env: | |
OSSRH_USERNAME: ${{ secrets.OSSRH_USERNAME }} | |
OSSRH_TOKEN: ${{ secrets.OSSRH_TOKEN }} | |
GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }} | |
- name: Promote staging release | |
if: ${{ ! inputs.dry-run }} | |
run: |- | |
./scripts/close-nexus-repository.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: Upload site | |
uses: actions/upload-pages-artifact@v2 | |
with: | |
path: target/site | |
- name: Deploy site | |
if: ${{ !inputs.dry-run }} | |
id: site | |
uses: actions/deploy-pages@v2 | |
- name: Create GitHub Release | |
if: ${{ ! inputs.dry-run }} | |
uses: ncipollo/release-action@v1 | |
with: | |
tag: v${{ env.release_version }} | |
name: v${{ env.release_version }} | |
generateReleaseNotes: true | |
token: ${{ secrets.GITHUB_TOKEN }} | |