Skip to content

Commit

Permalink
Merge pull request #265 from vivid-money/publish-to-maven
Browse files Browse the repository at this point in the history
Add publish to maven workflow
  • Loading branch information
trdelnk authored Jun 19, 2024
2 parents fb50f37 + 6d2c2fe commit 59432b2
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 2 deletions.
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

0 comments on commit 59432b2

Please sign in to comment.