Skip to content

Commit 46d2dbb

Browse files
Automate deploy with GHA (#946)
1 parent e4b739f commit 46d2dbb

File tree

4 files changed

+63
-55
lines changed

4 files changed

+63
-55
lines changed

.github/workflows/release.yml

+48
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
name: Sonatype Release
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
version:
7+
required: true
8+
9+
jobs:
10+
release:
11+
name: Release
12+
runs-on: 'ubuntu-latest'
13+
environment: main_env
14+
steps:
15+
- uses: actions/checkout@v4
16+
- name: Configure GHA bot # used to commit release and snapshot versions
17+
# GHA Bot (which sets next snapshot version) should be authenticated by actions/checkout, see:
18+
# https://github.com/actions/checkout/blob/main/README.md#push-a-commit-using-the-built-in-token
19+
run: |
20+
git config user.name "github-actions[bot]"
21+
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
22+
- name: Cache Maven packages
23+
uses: actions/cache@v4
24+
with:
25+
path: ~/.m2
26+
key: Linux-java11-m2-${{ hashFiles('**/pom.xml') }}
27+
restore-keys: Linux-java11-m2
28+
- name: Set up JDK 11
29+
uses: actions/setup-java@v4
30+
with:
31+
java-version: '11'
32+
distribution: 'adopt'
33+
# setup-java generates a settings.xml pointing deployments to Sonatype
34+
# See https://github.com/actions/setup-java/blob/v3.11.0/docs/advanced-usage.md#publishing-using-apache-maven
35+
server-id: ossrh
36+
server-username: SONATYPE_USERNAME
37+
server-password: SONATYPE_TOKEN
38+
gpg-private-key: ${{ secrets.GPG_KEY }}
39+
gpg-passphrase: MAVEN_GPG_PASSPHRASE
40+
- name: Release
41+
env:
42+
MAVEN_USERNAME: ${{ secrets.SONATYPE_USERNAME }}
43+
MAVEN_CENTRAL_TOKEN: ${{ secrets.SONATYPE_TOKEN }}
44+
MAVEN_GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}
45+
# Todo - remove dry-run flag once validated in GHA
46+
run: |
47+
export GPG_TTY=$(tty)
48+
mvn -B release:prepare release:perform -DreleaseVersion=${{ github.event.inputs.version }} -DdryRun=true

README.md

+12-1
Original file line numberDiff line numberDiff line change
@@ -286,12 +286,23 @@ expected to honor this code.
286286

287287
## Release
288288

289-
Every push to master will deploy a snapshot version to Sonatype.
289+
Trigger the [release](https://github.com/spotify/dbeam/actions/workflows/release.yml) workflow manually. This workflow requires a
290+
single input, `version`, which should be set to the desired semantic version in the format `{major_version}.{minor_version}.{patch_version}`.
291+
It will update versions in all `pom.xml` files, push a tag `vx.y.z`, package, sign, and deploy artifacts to Sonatype, and finally bump all
292+
`pom.xml`s to the next development SNAPSHOT version.
293+
290294
You can check the deployment in the following links:
291295

292296
- https://github.com/spotify/dbeam/actions
293297
- https://oss.sonatype.org/#nexus-search;quick~dbeam-core
294298

299+
You can also do a manual release. First, export env variables $SONATYPE_USERNAME, $SONATYPE_PASSWORD (for information on generating a token see [here](https://help.sonatype.com/en/user-tokens.html)), $MAVEN_GPG_KEY_NAME.
300+
Then, you can run `maven release` to deploy to Sonatype and automatically push commits bumping the project version:
301+
302+
```shell
303+
mvn -s sonatype-settings.xml -DreleaseVersion={NEW_VERSION} release:prepare release:perform # Run with -DdryRun=true first to validate pom modification
304+
```
305+
295306
## Future roadmap
296307

297308
DBeam is mature, maintained and used in production since August 2017. No major features or development planned.

github-settings.xml

-42
This file was deleted.

pom.xml

+3-12
Original file line numberDiff line numberDiff line change
@@ -92,9 +92,8 @@
9292
<url>https://oss.sonatype.org/service/local/staging/deploy/maven2/</url>
9393
</repository>
9494
<snapshotRepository>
95-
<id>github</id>
96-
<name>GitHub OWNER Apache Maven Packages</name>
97-
<url>https://maven.pkg.github.com/spotify/dbeam</url>
95+
<id>ossrh</id>
96+
<url>https://oss.sonatype.org/content/repositories/snapshots</url>
9897
</snapshotRepository>
9998
</distributionManagement>
10099

@@ -439,19 +438,11 @@
439438
<repositories>
440439
<repository>
441440
<releases>
442-
<enabled>false</enabled>
441+
<enabled>true</enabled>
443442
</releases>
444443
<snapshots>
445444
<enabled>true</enabled>
446445
</snapshots>
447-
<id>apache.snapshots</id>
448-
<name>Apache Development Snapshot Repository</name>
449-
<url>https://repository.apache.org/content/repositories/snapshots/</url>
450-
</repository>
451-
<repository>
452-
<snapshots>
453-
<enabled>false</enabled>
454-
</snapshots>
455446
<id>ossrh</id>
456447
<name>Sonatype OSS</name>
457448
<url>https://oss.sonatype.org/content/repositories/releases/</url>

0 commit comments

Comments
 (0)