Skip to content

Commit 9eb4246

Browse files
committed
Use new commit and push workflow
1 parent c8a1133 commit 9eb4246

File tree

4 files changed

+63
-8
lines changed

4 files changed

+63
-8
lines changed

.github/workflows/release.yml

+37-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
name: Release
2+
run-name: ${{ format('Release version {0}', inputs.version)}} by @${{ github.actor }}
23

34
on:
45
workflow_dispatch:
@@ -11,6 +12,7 @@ on:
1112
description: 'Next SNAPSHOT version (without v). Defaults to current value'
1213
required: false
1314
type: string
15+
pull_request:
1416

1517
jobs:
1618
publish:
@@ -42,14 +44,47 @@ jobs:
4244
# Disable writing to cache. Don't want to spoil the main cache
4345
cache-read-only: true
4446

45-
- name: Release
46-
run: ./scripts/release.sh ${{ inputs.version }} ${{ inputs.snapshot }}
47+
- name: Get Snaptshot versions
48+
id: snapshotVersions
49+
run: ./scripts/get_next_snapshot_version.sh ${{ inputs.snapshot }}
50+
51+
- name: Prepare for release metadata
52+
shell: bash
53+
run: |
54+
sed -i.bak "s/${{ steps.snapshotVersions.cur_snapshot_version }}/${{ steps.snapshotVersions.new_snapshot_version }}/g" gradle.properties
55+
56+
- name: Commit gradle.properties and set tag for v${{ inputs.version }}
57+
uses: IABTechLab/uid2-shared-actions/actions/commit_pr_and_merge@v2
58+
with:
59+
add: 'gradle.properties'
60+
message: 'Prepare for release: ${{ inputs.version }}'
61+
tag: v${{ inputs.version }}
62+
63+
- name: Deploy v${{ inputs.version }}
64+
run: ./gradlew publish
4765
env:
4866
ORG_GRADLE_PROJECT_mavenCentralUsername: ${{ secrets.SONATYPE_REPO_USERNAME }}
4967
ORG_GRADLE_PROJECT_mavenCentralPassword: ${{ secrets.SONATYPE_REPO_PASSWORD }}
5068
ORG_GRADLE_PROJECT_signingInMemoryKey: ${{ secrets.GPG_KEY }}
5169
ORG_GRADLE_PROJECT_signingInMemoryKeyPassword: ${{ secrets.GPG_PASSPHRASE }}
5270

71+
- name: Prepare next Snapshot version ${{ steps.snapshotVersions.new_snapshot_version }}
72+
shell: bash
73+
run: |
74+
echo "Setting next snapshot version ${{ steps.snapshotVersions.new_snapshot_version }}"
75+
sed -i.bak "s/${{ inputs.version }}/${{ steps.snapshotVersions.new_snapshot_version }}/g" gradle.properties
76+
77+
- name: Commit gradle.properties for Snapshot version ${{ steps.snapshotVersions.new_snapshot_version }}
78+
uses: IABTechLab/uid2-shared-actions/actions/commit_pr_and_merge@v2
79+
with:
80+
add: 'gradle.properties'
81+
message: 'Prepare next development version: ${{ steps.snapshotVersions.new_snapshot_version }}'
82+
83+
- name: Remove the backup file from sed edits
84+
shell: bash
85+
run: |
86+
rm gradle.properties.bak
87+
5388
- name: GitHub Release
5489
uses: softprops/action-gh-release@v1
5590
with:

scripts/get_snapshot_versions.sh

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#!/usr/bin/env bash
2+
3+
set -exo pipefail
4+
5+
# Gets a property out of a .properties file
6+
# usage: getProperty $key $filename
7+
function getProperty() {
8+
grep "${1}" "$2" | cut -d'=' -f2
9+
}
10+
11+
NEW_SNAPSHOT_VERSION=$1
12+
CUR_SNAPSHOT_VERSION=$(getProperty 'VERSION_NAME' gradle.properties)
13+
14+
if [ -z "$NEW_SNAPSHOT_VERSION" ]; then
15+
# If no snapshot version was provided, use the current value
16+
NEW_SNAPSHOT_VERSION=$CUR_SNAPSHOT_VERSION
17+
fi
18+
19+
20+
echo "new_snapshot_version=$NEW_SNAPSHOT_VERSION" >> $GITHUB_OUTPUT
21+
echo "cur_snapshot_version=$CUR_SNAPSHOT_VERSION" >> $GITHUB_OUTPUT
+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
2+
# Prepare next snapshot
3+
echo "Setting next snapshot version $NEW_SNAPSHOT_VERSION"
4+
sed -i.bak "s/${NEW_VERSION}/${NEW_SNAPSHOT_VERSION}/g" gradle.properties

scripts/release.sh

+1-6
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,7 @@ function getProperty() {
1010

1111
NEW_VERSION=$1
1212
NEW_SNAPSHOT_VERSION=$2
13-
CUR_SNAPSHOT_VERSION=$(getProperty 'VERSION_NAME' gradle.properties)
14-
15-
if [ -z "$NEW_SNAPSHOT_VERSION" ]; then
16-
# If no snapshot version was provided, use the current value
17-
NEW_SNAPSHOT_VERSION=$CUR_SNAPSHOT_VERSION
18-
fi
13+
CUR_SNAPSHOT_VERSION=$3
1914

2015
echo "Publishing $NEW_VERSION"
2116

0 commit comments

Comments
 (0)