11name : Release
2+ run-name : ${{ format('Release version {0}', inputs.version)}} by @${{ github.actor }}
23
34on :
45 workflow_dispatch :
@@ -17,18 +18,28 @@ jobs:
1718 runs-on : ubuntu-latest
1819
1920 permissions :
21+ pull-requests : write
2022 contents : write
23+ security-events : write
24+ packages : write
2125
2226 steps :
2327 - name : Checkout
24- uses : actions/checkout@v3
28+ uses : actions/checkout@v4
2529
2630 - name : Set up JDK 17
2731 uses : actions/setup-java@v3
2832 with :
2933 java-version : ' 17'
3034 distribution : ' temurin'
3135
36+ - name : Fail if Release and not on Default branch
37+ if : ${{ github.event.repository.default_branch != github.ref_name }}
38+ uses : actions/github-script@v7
39+ with :
40+ script : |
41+ core.setFailed('Releases can not be created on a feature branch. Branch: ${{ github.ref_name }}')
42+
3243 - name : Update Git user
3344 run : |
3445 git config --local user.name "IABTechLab"
@@ -42,14 +53,47 @@ jobs:
4253 # Disable writing to cache. Don't want to spoil the main cache
4354 cache-read-only : true
4455
45- - name : Release
46- run : ./scripts/release.sh ${{ inputs.version }} ${{ inputs.snapshot }}
56+ - name : Get Snaptshot versions
57+ id : snapshotVersions
58+ run : ./scripts/get_snapshot_versions.sh ${{ inputs.snapshot }}
59+
60+ - name : Prepare for release metadata
61+ shell : bash
62+ run : |
63+ sed -i.bak "s/${{ steps.snapshotVersions.outputs.cur_snapshot_version }}/${{ inputs.version }}/g" gradle.properties
64+
65+ - name : Commit gradle.properties and set tag for v${{ inputs.version }}
66+ uses : IABTechLab/uid2-shared-actions/actions/commit_pr_and_merge@v2
67+ with :
68+ add : ' gradle.properties'
69+ message : ' Prepare for release: ${{ inputs.version }}'
70+ tag : v${{ inputs.version }}
71+
72+ - name : Deploy v${{ inputs.version }}
73+ run : ./gradlew publish
4774 env :
4875 ORG_GRADLE_PROJECT_mavenCentralUsername : ${{ secrets.SONATYPE_REPO_USERNAME }}
4976 ORG_GRADLE_PROJECT_mavenCentralPassword : ${{ secrets.SONATYPE_REPO_PASSWORD }}
5077 ORG_GRADLE_PROJECT_signingInMemoryKey : ${{ secrets.GPG_KEY }}
5178 ORG_GRADLE_PROJECT_signingInMemoryKeyPassword : ${{ secrets.GPG_PASSPHRASE }}
5279
80+ - name : Prepare next Snapshot version ${{ steps.snapshotVersions.outputs.new_snapshot_version }}
81+ shell : bash
82+ run : |
83+ echo "Setting next snapshot version ${{ steps.snapshotVersions.outputs.new_snapshot_version }}"
84+ sed -i.bak "s/${{ inputs.version }}/${{ steps.snapshotVersions.outputs.new_snapshot_version }}/g" gradle.properties
85+
86+ - name : Commit gradle.properties for Snapshot version ${{ steps.snapshotVersions.outputs.new_snapshot_version }}
87+ uses : IABTechLab/uid2-shared-actions/actions/commit_pr_and_merge@v2
88+ with :
89+ add : ' gradle.properties'
90+ message : ' Prepare next development version: ${{ steps.snapshotVersions.outputs.new_snapshot_version }}'
91+
92+ - name : Remove the backup file from sed edits
93+ shell : bash
94+ run : |
95+ rm gradle.properties.bak
96+
5397 - name : GitHub Release
5498 uses : softprops/action-gh-release@v1
5599 with :
0 commit comments