Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

initial version for release action #2683

Draft
wants to merge 4 commits into
base: master
Choose a base branch
from
Draft
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
98 changes: 98 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
# Automates the release steps outlined at https://github.com/Adobe-Consulting-Services/acs-aem-commons/blob/master/RELEASING.md
name: Release to Sonatype OSSRH (Maven Central)

# Only support manual trigger (https://docs.github.com/en/actions/managing-workflow-runs/manually-running-a-workflow)
on:
workflow_dispatch:
inputs:
releaseVersion:
description: 'Release version (major.minor.patch)'
required: false
default: ''
email:
description: 'Email Release Manager'
required: true
default: ''
dryRun:
description: 'Dry Run? (false to do an actual release)'
required: true
default: 'true'
jobs:
release:
runs-on: ubuntu-latest
steps:
- name: Enforce master branch
if: github.ref != 'refs/heads/master'
uses: actions/github-script@v3
with:
script: |
core.setFailed('Releases can only be triggered from master branch!')

# Check out Git repository
- name: Checkout
uses: actions/checkout@v2

# Set up environment with Java and Maven
- name: Set up JDK
uses: actions/setup-java@v2
with:
cache: 'maven'
distribution: 'adopt'
java-version: 8
# generate settings.xml with the correct values
server-id: ossrh # Value of the distributionManagement/repository/id field of the pom.xml
server-username: MAVEN_USERNAME # env variable for username in deploy
server-password: MAVEN_PASSWORD # env variable for token in deploy
gpg-private-key: ${{ secrets.GPG_PRIVATE_KEY }} # Value of the GPG private key to import
gpg-passphrase: MAVEN_GPG_PASSPHRASE # env variable for GPG private key passphrase

- name: Configure git user for release commits
run: |
git config user.email "${{ github.event.inputs.email }}"
git config user.name "${{ github.actor }}"

# Build and deploy to OSSRH, which will automatically sync to Central Repository
- name: Build and Deploy ${{ github.event.inputs.releaseVersion }} to Central Repository
env:
MAVEN_GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}
MAVEN_USERNAM: ${{ secrets.OSSRH_TOKEN_USER }}
MAVEN_PASSWORD: ${{ secrets.OSSRH_TOKEN_PASSWORD }}
run: mvn -B clean release:prepare release:perform -DreleaseVersion=${{ github.event.inputs.releaseVersion }} -DdryRun=${{ github.event.inputs.dryRun }}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

- name: Close milestone ${{ github.event.inputs.releaseVersion }}
if: !github.event.inputs.dryRun
uses: Beakyn/[email protected]
env:
GITHUB_TOKEN: ${{ github.token }}
with:
repository: ${{ github.repository }}
milestone-title: ${{ github.event.inputs.releaseVersion }}

- name: Build Changelog
id: github_release
uses: okcredit/changelog-creator-action@{latest-release}
with:
milestone: ${{ github.event.inputs.releaseVersion }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Create Release
if: !github.event.inputs.dryRun
uses: actions/create-release@v1
with:
tag_name: ${{ github.event.inputs.releaseVersion }}
release_name: ${{ steps.github_release.outputs.milestone }}
body: ${{ steps.github_release.outputs.changelog }}
draft: ${{ github.event.inputs.dryRun }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Create Draft Release
if: !github.event.inputs.dryRun
uses: actions/create-release@v1
with:
release_name: ${{ steps.github_release.outputs.milestone }}
body: ${{ steps.github_release.outputs.changelog }}
draft: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}