Release to OSSRH #57
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | |
# Copyright 2022 Adobe Systems Incorporated | |
# | |
# Licensed under the Apache License, Version 2.0 (the "License"); | |
# you may not use this file except in compliance with the License. | |
# You may obtain a copy of the License at | |
# | |
# http://www.apache.org/licenses/LICENSE-2.0 | |
# | |
# Unless required by applicable law or agreed to in writing, software | |
# distributed under the License is distributed on an "AS IS" BASIS, | |
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
# See the License for the specific language governing permissions and | |
# limitations under the License. | |
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | |
name: Release to OSSRH | |
on: | |
workflow_dispatch: | |
inputs: | |
releaseVersion: | |
description: 'Release version (major.minor.patch - patch should be even number)' | |
required: false | |
dryRun: | |
description: 'Dry Run? (uncheck to perform a release)' | |
required: true | |
type: boolean | |
default: true | |
jobs: | |
Tag: | |
runs-on: ubuntu-latest | |
# Only release from `main` branch | |
if: github.repository == 'adobe/asset-share-commons' && github.ref == 'refs/heads/main' | |
outputs: | |
version: ${{ steps.store-version.outputs.version }} | |
steps: | |
# Check out Git repository | |
- uses: actions/checkout@v4 | |
# Set up environment with Java and Maven | |
- name: Setup JDK | |
uses: actions/setup-java@v4 | |
with: | |
distribution: 'temurin' | |
java-version: 8 | |
cache: maven | |
- name: Initialize mandatory git config | |
run: | | |
git config user.name "GitHub Actions" | |
git config user.email [email protected] | |
- name: Tag DryRun with Maven | |
if: ${{ inputs.dryRun }} | |
run: mvn -B release:clean release:prepare -DreleaseVersion=${{ inputs.releaseVersion }} -DdryRun=true -Pcloud | |
- name: Tag with Maven | |
if: ${{ !inputs.dryRun }} | |
run: mvn -B release:clean release:prepare -DreleaseVersion=${{ inputs.releaseVersion }} -Pcloud | |
- name: Store Version | |
id: store-version | |
run: echo "version=$(grep ^scm.tag= release.properties | sed -e 's/scm.tag=asset-share-commons-//g')" >> $GITHUB_OUTPUT | |
Github_Release: | |
needs: Tag | |
runs-on: ubuntu-latest | |
if: ${{ !inputs.dryRun }} | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
ref: asset-share-commons-${{ needs.Tag.outputs.version }} | |
- name: Setup JDK | |
uses: actions/setup-java@v4 | |
with: | |
distribution: 'temurin' | |
java-version: 11 | |
cache: maven | |
- name: Maven Verify | |
run: mvn -U clean verify -Pcloud | |
- name: Generate Release Changelog | |
id: generate-release-changelog | |
uses: mikepenz/release-changelog-builder-action@v4 | |
with: | |
token: ${{ secrets.GITHUB_TOKEN }} | |
configuration: ".github/.release-changelog-config.json" | |
toTag: asset-share-commons-${{ needs.Tag.outputs.version }} | |
- name: Create Release | |
id: create-release | |
uses: actions/create-release@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
tag_name: asset-share-commons-${{ needs.Tag.outputs.version }} | |
release_name: asset-share-commons-${{ needs.Tag.outputs.version }} | |
body: ${{ steps.generate-release-changelog.outputs.changelog }} | |
draft: false | |
prerelease: false | |
- name: Upload Release Artifacts | |
id: upload-release-artifacts | |
uses: softprops/action-gh-release@v2 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
tag_name: asset-share-commons-${{ needs.Tag.outputs.version }} | |
files: | | |
all/target/asset-share-commons.all-*.zip | |
ui.content.sample/target/asset-share-commons.ui.content.sample-*.zip | |
Maven_Central_Deploy: | |
needs: Tag | |
runs-on: ubuntu-latest | |
if: ${{ !inputs.dryRun }} | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
with: | |
ref: asset-share-commons-${{ needs.Tag.outputs.version }} | |
- name: Setup JDK | |
uses: actions/setup-java@v4 | |
with: | |
distribution: 'temurin' | |
java-version: 8 | |
cache: maven | |
server-id: ossrh | |
server-username: MAVEN_USERNAME | |
server-password: MAVEN_CENTRAL_TOKEN | |
gpg-private-key: ${{ secrets.MAVEN_GPG_PRIVATE_KEY }} | |
gpg-passphrase: MAVEN_GPG_PASSPHRASE | |
- name: Import GPG key | |
env: | |
GPG_SECRET_KEYS: ${{ secrets.GPG_SECRET_KEYS }} | |
GPG_OWNERTRUST: ${{ secrets.GPG_OWNERTRUST }} | |
run: | | |
echo $GPG_SECRET_KEYS | base64 --decode | gpg --import --no-tty --batch --yes | |
echo $GPG_OWNERTRUST | base64 --decode | gpg --import-ownertrust --no-tty --batch --yes | |
# Keeping these separate in case multiple builds are needed. | |
- name: Build | |
run: mvn clean deploy -DskipRemoteStaging=true -Pcloud,release | |
env: | |
MAVEN_USERNAME: ${{ secrets.SONATYPE_USERNAME }} | |
MAVEN_CENTRAL_TOKEN: ${{ secrets.SONATYPE_PASSWORD }} | |
MAVEN_GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }} | |
- name: Deploy to Central | |
run: mvn nexus-staging:deploy-staged -DautoReleaseAfterClose=true | |
env: | |
MAVEN_USERNAME: ${{ secrets.SONATYPE_USERNAME }} | |
MAVEN_CENTRAL_TOKEN: ${{ secrets.SONATYPE_PASSWORD }} | |
MAVEN_GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }} | |
Changelog: | |
runs-on: ubuntu-latest | |
needs: Tag | |
if: ${{ !inputs.dryRun }} | |
steps: | |
- name: "Checkout" | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
ref: main | |
- name: "Build Changelog Fragment" | |
id: build_changelog_fragment | |
uses: mikepenz/release-changelog-builder-action@v4 | |
with: | |
token: ${{ secrets.GITHUB_TOKEN }} | |
configuration: ".github/.release-changelog-config.json" | |
toTag: asset-share-commons-${{ needs.Tag.outputs.version }} | |
- name: "Build Changelog" | |
run: | | |
echo -e "${{steps.build_changelog_fragment.outputs.changelog}}" | cat - CHANGELOG_HISTORY.md > tmp | |
mv tmp CHANGELOG_HISTORY.md | |
echo -e '# 📑 Changelog\n\n' | cat - CHANGELOG_HISTORY.md > CHANGELOG.md | |
- name: Commit Changelog | |
run: | | |
git config user.name "GitHub Actions" | |
git config user.email [email protected] | |
git add CHANGELOG.md | |
git add CHANGELOG_HISTORY.md | |
git commit -m 'Update Changelog.' | |
git push | |
Sync_develop: | |
needs: Changelog | |
if: ${{ !inputs.dryRun }} | |
uses: ./.github/workflows/sync-develop.yaml |