-
Notifications
You must be signed in to change notification settings - Fork 67
77 lines (65 loc) · 2.6 KB
/
publish_release.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
name: Publish Release
# Every time we merge to main branch we publish a release.
on:
push:
branches: [ main ]
workflow_dispatch:
jobs:
publish-release:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
ref: main
- name: Set up JDK
uses: actions/setup-java@v3
with:
distribution: 'zulu'
java-version: 17
cache: 'gradle'
- name: Grant execute permission for gradlew
run: chmod +x gradlew
- name: Gradle check
run: ./gradlew check --no-daemon
# TODO: add more tests or rely on check_release workflow?
# Base64 decodes and pipes the GPG key content into the secret file
- name: Prepare environment
env:
GPG_KEY_CONTENTS: ${{ secrets.GPG_KEY_CONTENTS }}
SIGNING_SECRET_KEY_RING_FILE: ${{ secrets.SIGNING_SECRET_KEY_RING_FILE }}
run: |
git fetch --unshallow
sudo bash -c "echo '$GPG_KEY_CONTENTS' | base64 -d > '$SIGNING_SECRET_KEY_RING_FILE'"
# Packages and publishes to Maven Central
- name: Publish to Maven Central
run: ./gradlew publishReleasePublicationToSonatypeRepository --max-workers 1 --stacktrace --no-daemon
env:
OSSRH_USERNAME: ${{ secrets.OSSRH_USERNAME }}
OSSRH_PASSWORD: ${{ secrets.OSSRH_PASSWORD }}
SIGNING_KEY_ID: ${{ secrets.SIGNING_KEY_ID }}
SIGNING_PASSWORD: ${{ secrets.SIGNING_PASSWORD }}
SIGNING_SECRET_KEY_RING_FILE: ${{ secrets.SIGNING_SECRET_KEY_RING_FILE }}
SONATYPE_STAGING_PROFILE_ID: ${{ secrets.SONATYPE_STAGING_PROFILE_ID }}
# Get the version name from a script and save to environment variable.
- name: Set PROJECT_VERSION
run: |
echo "▸ Set run permission."
chmod +x scripts/version_name.sh
echo "▸ Getting version name"
PROJECT_VERSION=$(./scripts/version_name.sh)
echo "▸ Variable PROJECT_VERSION set to: ${PROJECT_VERSION}"
echo "▸ Adding PROJECT_VERSION variable with: $PROJECT_VERSION"
echo "PROJECT_VERSION=$PROJECT_VERSION" >> $GITHUB_ENV
echo "▸ DONE"
# Create the Release TAG and notes.
- name: Create GitHub Release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
commitish: main
tag_name: ${{ env.PROJECT_VERSION }}
release_name: ${{ env.PROJECT_VERSION }}
body_path: ${{ github.workspace }}/RELEASE_NOTES.md
draft: false
prerelease: false