Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
94 changes: 94 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
name: Release
on:
push:
branches: ['main']
paths:
- '.github/workflows/release.yml'
- 'pom.xml'
workflow_dispatch:
inputs:
publish_to_package_manager:
description: 'Override PUBLISH_TO_PACKAGE_MANAGER for this run'
type: boolean
default: false

env:
# Toggle to enable package-manager publishing on push to base.
# The workflow_dispatch input above overrides this on manual runs.
# Quoted so the value is always compared as a string (see the gate step below).
PUBLISH_TO_PACKAGE_MANAGER: 'false'
# SDK identity baked in at generation time from the in-memory build context,
# so the workflow never reads pom.xml at runtime.
SDK_VERSION: '4.0.0'
SDK_GROUP_ID: 'com.alohi'
SDK_ARTIFACT_ID: 'signplus'
RELEASE_TAG: 'v4.0.0'

jobs:
release:
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v4
- name: Create tag if it does not exist
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
if gh api "repos/${{ github.repository }}/git/refs/tags/$RELEASE_TAG" >/dev/null 2>&1; then
echo "::notice::Tag $RELEASE_TAG already exists, nothing to do"
exit 0
fi
gh api -X POST "repos/${{ github.repository }}/git/refs" \
-f ref="refs/tags/$RELEASE_TAG" \
-f sha="${{ github.sha }}"
echo "::notice::Created tag $RELEASE_TAG at ${{ github.sha }}"
- name: Compute publish gate
id: gate
run: |
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
echo "ok=${{ inputs.publish_to_package_manager }}" >> "$GITHUB_OUTPUT"
else
echo "ok=$PUBLISH_TO_PACKAGE_MANAGER" >> "$GITHUB_OUTPUT"
fi
# Maven Central (Sonatype) requires GPG-signed artifacts plus -sources and
# -javadoc jars. The generated pom.xml attaches those via the
# `release-sign-artifacts` profile (activated by -DperformRelease=true) and
# publishes through the central-publishing-maven-plugin (server id: central).
- uses: actions/setup-java@v4
if: steps.gate.outputs.ok == 'true'
with:
distribution: 'temurin'
java-version: '11'
server-id: 'central'
server-username: MAVEN_CENTRAL_USERNAME
server-password: MAVEN_CENTRAL_PASSWORD
gpg-private-key: ${{ secrets.GPG_PRIVATE_KEY }}
gpg-passphrase: GPG_PASSPHRASE
- name: Publish to Maven Central
if: steps.gate.outputs.ok == 'true'
# Idempotent: Maven Central is immutable, so re-running for an
# already-published version (e.g. enabling publishing on an existing
# tag) skips the deploy instead of failing.
run: |
GROUP_PATH="${SDK_GROUP_ID//./\/}"
POM_URL="https://repo1.maven.org/maven2/${GROUP_PATH}/${SDK_ARTIFACT_ID}/${SDK_VERSION}/${SDK_ARTIFACT_ID}-${SDK_VERSION}.pom"
if curl -sfI "$POM_URL" >/dev/null 2>&1; then
echo "::notice::$SDK_GROUP_ID:$SDK_ARTIFACT_ID:$SDK_VERSION already published to Maven Central, skipping deploy"
else
mvn --batch-mode -DperformRelease=true -DskipTests deploy
fi
env:
MAVEN_CENTRAL_USERNAME: ${{ secrets.MAVEN_CENTRAL_USERNAME }}
MAVEN_CENTRAL_PASSWORD: ${{ secrets.MAVEN_CENTRAL_PASSWORD }}
GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}
- name: Create GitHub release
if: steps.gate.outputs.ok == 'true'
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
if gh release view "$RELEASE_TAG" >/dev/null 2>&1; then
echo "::notice::Release $RELEASE_TAG already exists"
else
gh release create "$RELEASE_TAG" --title "$RELEASE_TAG" --generate-notes
fi
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ build/
gradle-app.setting
!gradle-wrapper.jar

# Kotlin
.kotlin

# IntelliJ
out/
.idea/
Expand Down
15 changes: 15 additions & 0 deletions .idea/compiler.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 11 additions & 0 deletions .idea/encoding.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

25 changes: 25 additions & 0 deletions .idea/jarRepositories.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 14 additions & 0 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

78 changes: 78 additions & 0 deletions .idea/workspace.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading