Skip to content

Commit b347aa5

Browse files
authored
fix(release): use current Central Portal for package publishing (#64)
* fix(release): use current Central Portal for package publishing * fix(release): split staging and release into two jobs, with approval on release * fix(release): add version to gradle properties to tag staging package
1 parent 7e65d7c commit b347aa5

5 files changed

Lines changed: 80 additions & 25 deletions

File tree

‎.github/workflows/release.yml‎

Lines changed: 68 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,19 @@ on:
66
- master
77
- main
88

9+
concurrency:
10+
group: release
11+
cancel-in-progress: false
12+
13+
permissions:
14+
contents: write
15+
pull-requests: write
16+
917
jobs:
10-
changesets:
18+
stage:
1119
runs-on: ubuntu-latest
20+
outputs:
21+
tag: ${{ steps.release.outputs.tag }}
1222
env:
1323
SONATYPE_USERNAME: ${{ secrets.SONATYPE_USERNAME }}
1424
SONATYPE_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }}
@@ -50,28 +60,65 @@ jobs:
5060
version-script: npm run version
5161
github-token: ${{ secrets.GITHUB_TOKEN }}
5262

53-
- name: Create new release if release PR is merged
63+
- name: Tag and create GitHub release if release PR is merged
64+
id: release
5465
if: steps.changesets.outputs.has-changesets == 'false'
66+
env:
67+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
5568
run: |
5669
npx changeset git-tag && git push origin --tags
5770
COMMIT_TAG=$(git tag --points-at HEAD)
58-
if [ -n "$COMMIT_TAG" ]; then
59-
echo "A tag is attached to HEAD. Creating a new release..."
60-
echo "${{ secrets.GITHUB_TOKEN }}" | gh auth login --with-token
61-
CHANGELOG=$(awk '
62-
BEGIN { recording=0; }
63-
/^## / {
64-
if(recording) { exit; }
65-
recording=1;
66-
next;
67-
}
68-
recording {
69-
print;
70-
}
71-
' CHANGELOG.md)
72-
gh release create $COMMIT_TAG -t "$COMMIT_TAG" -n "$CHANGELOG"
73-
./generate_gradle_properties.bash ${{ github.workspace }}
74-
./gradlew publishToSonatype closeAndReleaseSonatypeStagingRepository
75-
else
71+
if [ -z "$COMMIT_TAG" ]; then
7672
echo "No tag attached to HEAD. No new release needed."
77-
fi
73+
exit 0
74+
fi
75+
echo "A tag is attached to HEAD. Creating a new release..."
76+
CHANGELOG=$(awk '
77+
BEGIN { recording=0; }
78+
/^## / {
79+
if(recording) { exit; }
80+
recording=1;
81+
next;
82+
}
83+
recording {
84+
print;
85+
}
86+
' CHANGELOG.md)
87+
gh release create "$COMMIT_TAG" -t "$COMMIT_TAG" -n "$CHANGELOG"
88+
echo "tag=$COMMIT_TAG" >> "$GITHUB_OUTPUT"
89+
90+
- name: Stage ${{ steps.release.outputs.tag }} to Sonatype
91+
if: steps.release.outputs.tag != ''
92+
run: |
93+
./generate_gradle_properties.bash ${{ github.workspace }}
94+
./gradlew publishToSonatype closeSonatypeStagingRepository
95+
96+
publish:
97+
needs: stage
98+
if: needs.stage.outputs.tag != ''
99+
runs-on: ubuntu-latest
100+
environment:
101+
name: maven-central
102+
url: https://central.sonatype.com/publishing/deployments
103+
env:
104+
SONATYPE_USERNAME: ${{ secrets.SONATYPE_USERNAME }}
105+
SONATYPE_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }}
106+
GPG_KEY_FILE: ${{ secrets.GPG_KEY_FILE }}
107+
GPG_KEY_PASSWORD: ${{ secrets.GPG_KEY_PASSWORD }}
108+
GPG_KEY_ID: ${{ secrets.GPG_KEY_ID }}
109+
steps:
110+
- name: Checkout release tag
111+
uses: actions/checkout@v7
112+
with:
113+
ref: ${{ needs.stage.outputs.tag }}
114+
115+
- name: Setup java environment
116+
uses: actions/setup-java@v6
117+
with:
118+
distribution: 'corretto'
119+
java-version: '17'
120+
121+
- name: Release ${{ needs.stage.outputs.tag }} to Maven Central
122+
run: |
123+
./generate_gradle_properties.bash ${{ github.workspace }}
124+
./gradlew findSonatypeStagingRepository releaseSonatypeStagingRepository

‎CHANGELOG.md‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# evervault-java
22

3+
## 4.3.1
4+
5+
### Patch Changes
6+
7+
- Update release process from deprecated OSSRH to Maven Central Portal.
8+
39
## 4.3.0
410

511
### Minor Changes

‎build.gradle‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ plugins {
99
}
1010

1111
group 'com.evervault'
12+
version new groovy.json.JsonSlurper().parseText(file('package.json').text).version
1213

1314
dependencyLocking {
1415
lockAllConfigurations()
@@ -25,8 +26,9 @@ def getRepositoryPassword() {
2526
nexusPublishing {
2627
repositories {
2728
sonatype {
28-
nexusUrl.set(uri("https://s01.oss.sonatype.org/service/local/"))
29-
snapshotRepositoryUrl.set(uri("https://s01.oss.sonatype.org/content/repositories/snapshots/"))
29+
nexusUrl.set(uri("https://ossrh-staging-api.central.sonatype.com/service/local/"))
30+
snapshotRepositoryUrl.set(uri("https://central.sonatype.com/repository/maven-snapshots/"))
31+
stagingProfileId.set("7050c947df3733")
3032
username = getRepositoryUsername()
3133
password = getRepositoryPassword()
3234
}

‎lib/build.gradle‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ plugins {
66
}
77

88
group 'com.evervault'
9-
version '4.3.0'
9+
version '4.3.1'
1010

1111
repositories {
1212
mavenCentral()

‎package.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "evervault-java",
33
"private": true,
4-
"version": "4.3.0",
4+
"version": "4.3.1",
55
"scripts": {
66
"version": "changeset version && PACKAGE_VERSION=$(node -p \"require('./package.json').version\") && sed -i \"s/version '.*'/version '$PACKAGE_VERSION'/g\" lib/build.gradle"
77
},

0 commit comments

Comments
 (0)