Skip to content

Commit e71a912

Browse files
authored
ci: automate release workflow for snapshots and stable versions (#1579)
1 parent 92245ce commit e71a912

4 files changed

Lines changed: 72 additions & 102 deletions

File tree

‎.github/maintainers_guide.md‎

Lines changed: 9 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -106,58 +106,11 @@ Refer to the [README](https://github.com/slackapi/java-slack-sdk/blob/main/docs/
106106

107107
### Releasing
108108

109-
#### Prerequisites
110-
111-
* If you don't have `gnu-sed`, run `brew install gnu-sed` & `brew install gnupg`
112-
* Make sure you've set up your key https://central.sonatype.org/publish/requirements/gpg/
113-
* Make sure the account you are using has the permission to make releases [under com.slack groupId](https://central.sonatype.com/publishing/com.slack/users)
114-
115-
Place `$HOME/.m2/settings.xml` with your Sonatype account information.
116-
* Generate user token: https://central.sonatype.org/publish/generate-portal-token/
117-
* Set the user token id/password: https://central.sonatype.org/publish/publish-portal-maven/#credentials
118-
119-
```xml
120-
<settings>
121-
<localRepository>/${your-home-dir}/.m2/repository</localRepository>
122-
<servers>
123-
<server>
124-
<id>central</id>
125-
<username>${your-username}</username>
126-
<password>${your-password}</password>
127-
</server>
128-
<server>
129-
<id>central-snapshots</id>
130-
<username>${your-username}</username>
131-
<password>${your-password}</password>
132-
</server>
133-
</servers>
134-
<pluginGroups>
135-
<pluginGroup>org.apache.maven.plugins</pluginGroup>
136-
<pluginGroup>org.codehaus.mojo</pluginGroup>
137-
</pluginGroups>
138-
</settings>
139-
```
140-
141109
#### Snapshot Release
142110

143-
Snapshot releases are intended for developers to make pre-release versions of their projects available for testing.
144-
To learn more about snapshot releases in maven central repository check out [publish-portal-snapshots](https://central.sonatype.org/publish/publish-portal-snapshots/)
111+
Snapshot releases are published by starting and approving the [release workflow](https://github.com/slackapi/java-slack-sdk/actions/workflows/release.yml) with `workflow_dispatch` for any branch with a `-SNAPSHOT` version, including the `main` branch.
145112

146-
* From the upstream repository
147-
* Preparation
148-
* `git switch main && git pull origin main` (or the branch you want to release from)
149-
* Make sure there are no build failures at https://github.com/slackapi/java-slack-sdk/actions
150-
* Set a new version
151-
* It is **critical** that the version ends with `-SNAPSHOT`. This is how [central-publishing-maven-plugin](https://central.sonatype.org/publish/publish-portal-snapshots/#publishing-with-the-central-publishing-maven-plugin) automatically recognizes snapshot releases and uploads them the right location.
152-
* If you don't have `gnu-sed`, check out [Prerequisites](#prerequisites)
153-
* Run `scripts/set_version.sh (the version)` (e.g., `scripts/set_version.sh 1.0.0-SNAPSHOT`)
154-
* Ship the libraries
155-
* Switch to **JDK 17** to publish all modules (on macOS, you can run `export JAVA_HOME=$(/usr/libexec/java_home -v 17)` for it)
156-
* Run `scripts/release.sh` (it takes a bit long)
157-
* (If you encounter an error, log in https://oss.sonatype.org/ to check detailed information)
158-
* No need to create a GitHub Release, since this is intended for developers to make pre-release versions of their projects.
159-
* `-SNAPSHOT` versions are intended to be overwritten.
160-
* This enables developers to work with the latest version of a library without needing to update their dependencies repeatedly.
113+
These `-SNAPSHOT` versions are intended to be overwritten. This enables developers to work with the latest version of a library without needing to update their dependencies repeatedly. To learn more about snapshot releases in maven central repository check out [publish-portal-snapshots](https://central.sonatype.org/publish/publish-portal-snapshots/).
161114

162115
#### Stable Release
163116

@@ -166,19 +119,16 @@ To learn more about snapshot releases in maven central repository check out [pub
166119
* `git switch main && git pull origin main`
167120
* Make sure there are no build failures at https://github.com/slackapi/java-slack-sdk/actions
168121
* Set a new version
169-
* If you don't have `gnu-sed`, check out [Prerequisites](#prerequisites)
170-
* Run `scripts/set_version.sh (the version)` (e.g., `scripts/set_version.sh 1.0.0`)
171-
* Ship the libraries
172-
* Switch to **JDK 17** to publish all modules (on macOS, you can run `export JAVA_HOME=$(/usr/libexec/java_home -v 17)` for it)
173-
* Run `scripts/release.sh` (it takes a bit long)
174-
* (If you encounter an error, log in https://oss.sonatype.org/ to check detailed information)
175-
* Create GitHub Release(s) and add release notes
176-
* [Look at previous releases](https://github.com/slackapi/java-slack-sdk/releases) and follow their layouts
177-
* Prepare a release note by `git log --pretty=format:'%h %s by %an' --abbrev-commit | grep -v "Merge pull request " | head -50`
122+
* Run `scripts/set_version.sh (the version)` (e.g., `scripts/set_version.sh 1.0.0`) — requires `gnu-sed` on macOS (`brew install gnu-sed`)
178123
* `git add . -v && git commit -m'version (your version here)'`
179124
* `git tag v(your version here)`
180-
* `git push & git push --tags`
125+
* `git push && git push --tags`
126+
* Publish to Maven Central
127+
* Start and approve the [release workflow](https://github.com/slackapi/java-slack-sdk/actions/workflows/release.yml) using `workflow_dispatch` on `main`
128+
* Create a GitHub Release
181129
* Open https://github.com/slackapi/java-slack-sdk/releases/new?tag=v${version}
130+
* [Look at previous releases](https://github.com/slackapi/java-slack-sdk/releases) and follow their layouts
131+
* Prepare a release note by `git log --pretty=format:'%h %s by %an' --abbrev-commit | grep -v "Merge pull request " | head -50`
182132
* (Slack Internal) Communicate the release internally. Include a link to the GitHub Release(s).
183133
* (Slack Internal) Tweet? Not necessary for patch updates, might be needed for minor updates, definitely needed for
184134
major updates. Include a link to the GitHub Release(s).

‎.github/workflows/release.yml‎

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
name: Release
2+
3+
on:
4+
workflow_dispatch:
5+
6+
jobs:
7+
publish:
8+
name: Publish
9+
if: github.repository == 'slackapi/java-slack-sdk'
10+
runs-on: ubuntu-latest
11+
environment: central
12+
permissions:
13+
contents: read
14+
steps:
15+
- name: Checkout the repo
16+
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1
17+
with:
18+
persist-credentials: false
19+
20+
- name: Set up JDK 17
21+
uses: actions/setup-java@c1e323688fd81a25caa38c78aa6df2d33d3e20d9 # v4.8.0
22+
with:
23+
java-version: "17"
24+
distribution: "adopt"
25+
server-id: central
26+
server-username: MAVEN_USERNAME
27+
server-password: MAVEN_PASSWORD
28+
gpg-private-key: ${{ secrets.GPG_KEY }}
29+
gpg-passphrase: MAVEN_GPG_PASSPHRASE
30+
31+
- name: Add snapshot server credentials
32+
run: |
33+
sed -i '/<\/servers>/i \
34+
<server>\
35+
<id>central-snapshots</id>\
36+
<username>${env.MAVEN_USERNAME}</username>\
37+
<password>${env.MAVEN_PASSWORD}</password>\
38+
</server>' ~/.m2/settings.xml
39+
40+
- name: Configure GPG
41+
run: |
42+
echo "use-agent" >> ~/.gnupg/gpg.conf
43+
echo "pinentry-mode loopback" >> ~/.gnupg/gpg.conf
44+
echo "allow-loopback-pinentry" >> ~/.gnupg/gpg-agent.conf
45+
echo RELOADAGENT | gpg-connect-agent
46+
47+
- name: Publish to Maven Central
48+
run: |
49+
./mvnw clean deploy \
50+
-P production-releases \
51+
-D maven.test.skip=true \
52+
-D gpg.passphrase="${MAVEN_GPG_PASSPHRASE}" \
53+
-pl !bolt-kotlin-examples \
54+
-pl !bolt-quarkus-examples \
55+
--batch-mode \
56+
--no-transfer-progress
57+
env:
58+
MAVEN_USERNAME: ${{ secrets.MAVEN_USERNAME }}
59+
MAVEN_PASSWORD: ${{ secrets.MAVEN_PASSWORD }}
60+
MAVEN_GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}
61+
MAVEN_OPTS: "--add-opens=java.base/java.util=ALL-UNNAMED --add-opens=java.base/java.lang.reflect=ALL-UNNAMED --add-opens=java.base/java.text=ALL-UNNAMED --add-opens=java.desktop/java.awt.font=ALL-UNNAMED"

‎AGENTS.md‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -608,8 +608,8 @@ Documentation: https://docs.slack.dev/tools/java-slack-sdk/guides/bolt-basics
608608

609609
Releases publish all modules simultaneously to Maven Central via Sonatype.
610610

611-
- **Snapshot**: Version must end with `-SNAPSHOT`. Run `scripts/set_version.sh 1.x.y-SNAPSHOT` then `scripts/release.sh`
612-
- **Stable**: Run `scripts/set_version.sh 1.x.y` then `scripts/release.sh`. Requires JDK 17, GPG signing, and Sonatype credentials in `~/.m2/settings.xml`
611+
- **Snapshot**: Trigger the [release workflow](.github/workflows/release.yml) via `workflow_dispatch` on any branch with a `-SNAPSHOT` version.
612+
- **Stable**: Run `scripts/set_version.sh 1.x.y`, commit, tag `v1.x.y`, push to `main`, then trigger the [release workflow](.github/workflows/release.yml) via `workflow_dispatch`.
613613
- Version is set across all `pom.xml` files AND three generated version classes (generated by `scripts/set_version.sh`):
614614
- `slack-api-model/src/main/java/com/slack/api/meta/SlackApiModelLibraryVersion.java`
615615
- `slack-api-client/src/main/java/com/slack/api/meta/SlackApiClientLibraryVersion.java`

‎scripts/release.sh‎

Lines changed: 0 additions & 41 deletions
This file was deleted.

0 commit comments

Comments
 (0)