Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add publish to maven workflow #265

Merged
merged 1 commit into from
Jun 19, 2024
Merged
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
4 changes: 2 additions & 2 deletions .github/sh/validate_publishing_branch.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
if [[ ${GITHUB_REF##*/} == main ]]; then
# Safe to publish from main branch
exit 0
elif [[ ${GITHUB_REF##*/} == publish* ]]; then
elif [[ ${GITHUB_REF##*/} == release* ]]; then
# Safe to publish from branches that have manually enabled publishing
exit 0
else
echo "::error ::Can only release from main branch or branches that start with 'publish'"
echo "::error ::Can only release from main branch or branches that start with 'release'"
exit 1
fi
48 changes: 48 additions & 0 deletions .github/workflows/publish-to-maven.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
name: Publish to Maven Central

on: workflow_dispatch

env:
NEW_VERSION: ${{ github.event.inputs.version }}
ORG_GRADLE_PROJECT_mavenCentralUsername: ${{ secrets.ORG_GRADLE_PROJECT_MAVENCENTRALUSERNAME }}
ORG_GRADLE_PROJECT_mavenCentralPassword: ${{ secrets.ORG_GRADLE_PROJECT_MAVENCENTRALPASSWORD }}
ORG_GRADLE_PROJECT_signingInMemoryKey: ${{ secrets.ORG_GRADLE_PROJECT_SIGNINGINMEMORYKEY }}
ORG_GRADLE_PROJECT_signingInMemoryKeyId: ${{ secrets.ORG_GRADLE_PROJECT_SIGNINGINMEMORYKEYID }}
ORG_GRADLE_PROJECT_signingInMemoryKeyPassword: ${{ secrets.ORG_GRADLE_PROJECT_SIGNINGINMEMORYKEYPASSWORD }}

jobs:
validate:
runs-on: macos-latest
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Setup node
uses: actions/setup-node@v4
with:
node-version: 20

- name: Validate Gradle Wrapper
uses: gradle/actions/wrapper-validation@v3

- name: Setup Java
uses: actions/setup-java@v3
with:
distribution: zulu
java-version: 17

- name: Setup Gradle
uses: gradle/actions/setup-gradle@v3

- name: Ensure main branch
run: ./.github/sh/validate_publishing_branch.sh

- name: Validate publishing
run: |
./gradlew \
-xtest \
-xlint \
publishToMavenLocal

- name: Publishing
run: ./gradlew publishToMavenCentral
Loading