Skip to content

Commit d6942cc

Browse files
author
Tim Evdokimov
committed
github action for sonatype publishing
1 parent b2fc937 commit d6942cc

File tree

1 file changed

+78
-0
lines changed

1 file changed

+78
-0
lines changed

.github/workflows/release.yml

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
name: Release to Sonatype
2+
3+
on:
4+
workflow_dispatch:
5+
push:
6+
branches:
7+
- master
8+
- main
9+
10+
permissions:
11+
contents: write # sbt-release will create tags and push commits
12+
13+
jobs:
14+
release:
15+
runs-on: ubuntu-latest
16+
timeout-minutes: 60
17+
env:
18+
# Trigger Publish.settings ReleaseToSonatype branch
19+
USERNAME: ${{ github.actor }}
20+
SONATYPE_USERNAME: ${{ secrets.SONATYPE_USERNAME }}
21+
SONATYPE_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }}
22+
PGP_PASSPHRASE: ${{ secrets.PGP_PASSPHRASE }}
23+
# gpg on headless runners
24+
GPG_TTY: /dev/pts/0
25+
steps:
26+
- name: Checkout
27+
# sbt-release needs tags and full history
28+
uses: actions/checkout@v4
29+
with:
30+
fetch-depth: 0
31+
32+
- name: Set up Java
33+
uses: actions/setup-java@v4
34+
with:
35+
distribution: temurin
36+
java-version: '17'
37+
cache: sbt
38+
39+
- name: Cache Ivy and Coursier
40+
uses: actions/cache@v4
41+
with:
42+
path: |
43+
~/.ivy2/cache
44+
~/.cache/coursier
45+
~/.sbt
46+
key: ${{ runner.os }}-sbt-${{ hashFiles('**/build.sbt', '**/project/**.sbt', '**/project/**.scala') }}
47+
restore-keys: |
48+
${{ runner.os }}-sbt-
49+
50+
- name: Import GPG private key
51+
if: secrets.GPG_PRIVATE_KEY != ''
52+
shell: bash
53+
run: |
54+
mkdir -p ~/.gnupg
55+
chmod 700 ~/.gnupg
56+
echo "pinentry-mode loopback" >> ~/.gnupg/gpg.conf
57+
echo "use-agent" >> ~/.gnupg/gpg.conf
58+
printf "%s" "${GPG_PRIVATE_KEY}" | gpg --batch --import
59+
env:
60+
GPG_PRIVATE_KEY: ${{ secrets.GPG_PRIVATE_KEY }}
61+
62+
- name: Show GPG keys (debug)
63+
if: always()
64+
run: |
65+
gpg --version
66+
gpg --list-keys || true
67+
gpg --list-secret-keys || true
68+
69+
- name: Configure Git identity for release
70+
run: |
71+
git config user.email "ci@users.noreply.github.com"
72+
git config user.name "GitHub Actions Release Bot"
73+
74+
- name: Run tests
75+
run: sbt "++2.13.16; test"
76+
77+
- name: Release to Sonatype (bundle + close + release)
78+
run: sbt "release with-defaults"

0 commit comments

Comments
 (0)