Skip to content

Commit 575647b

Browse files
authored
initial version for release action (#2683)
1 parent 935c106 commit 575647b

File tree

1 file changed

+73
-0
lines changed

1 file changed

+73
-0
lines changed

.github/workflows/release.yml

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
# Automates the release steps outlined at https://github.com/Adobe-Consulting-Services/acs-aem-commons/blob/master/RELEASING.md
2+
name: Release to GitHub and Maven Central
3+
4+
# Only support manual trigger (https://docs.github.com/en/actions/managing-workflow-runs/manually-running-a-workflow)
5+
on:
6+
workflow_dispatch:
7+
inputs:
8+
releaseVersion:
9+
description: 'Release version (major.minor.patch)'
10+
required: false
11+
default: ''
12+
email:
13+
description: 'Email Release Manager'
14+
required: true
15+
default: ''
16+
dryRun:
17+
description: 'Dry Run? (false to do an actual release)'
18+
required: true
19+
default: 'true'
20+
21+
permissions:
22+
contents: write
23+
24+
jobs:
25+
release:
26+
runs-on: ubuntu-latest
27+
steps:
28+
- name: Enforce master branch
29+
if: github.ref != 'refs/heads/master'
30+
uses: actions/github-script@v8
31+
with:
32+
script: |
33+
core.setFailed('Releases can only be triggered from master branch!')
34+
35+
# Check out Git repository
36+
- name: Checkout
37+
uses: actions/checkout@v5
38+
39+
# Set up environment with Java and Maven
40+
- name: Set up JDK
41+
uses: actions/setup-java@v5
42+
with:
43+
cache: 'maven'
44+
distribution: 'temurin'
45+
java-version: 21
46+
# generate settings.xml with the correct values
47+
server-id: sonatype-central-portal # Value of the distributionManagement/repository/id field of the pom.xml
48+
server-username: MAVEN_USERNAME # env variable for username in deploy
49+
server-password: MAVEN_PASSWORD # env variable for token in deploy
50+
gpg-private-key: ${{ secrets.GPG_PRIVATE_KEY }} # Value of the GPG private key to import
51+
gpg-passphrase: MAVEN_GPG_PASSPHRASE # env variable for GPG private key passphrase
52+
53+
- name: Configure git user for release commits
54+
run: |
55+
git config user.email "${{ github.event.inputs.email }}"
56+
git config user.name "${{ github.actor }}"
57+
58+
# Build and deploy to OSSRH, which will automatically sync to Central Repository
59+
- name: Build and Deploy ${{ github.event.inputs.releaseVersion }} to Central Repository
60+
env:
61+
MAVEN_GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}
62+
MAVEN_USERNAME: ${{ secrets.SONATYPE_CENTRAL_PORTAL_TOKEN_USER }}
63+
MAVEN_PASSWORD: ${{ secrets.SONATYPE_CENTRAL_PORTAL_TOKEN_PASSWORD }}
64+
run: mvn -B clean release:prepare release:perform -DreleaseVersion=${{ github.event.inputs.releaseVersion }} -DdryRun=${{ github.event.inputs.dryRun }} -Dnjord.dryRun=${{ github.event.inputs.dryRun }}
65+
66+
- name: Create Release
67+
uses: softprops/action-gh-release@v2
68+
with:
69+
tag_name: ${{ github.event.inputs.releaseVersion }}
70+
generate_release_notes: true
71+
draft: ${{ github.event.inputs.dryRun }}
72+
env:
73+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 commit comments

Comments
 (0)