Merge pull request #253 from HHS/dev #14
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
# This workflow will build a Java project with Maven, and cache/restore any dependencies to improve the workflow execution time | |
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-java-with-maven | |
# This workflow uses actions that are not certified by GitHub. | |
# They are provided by a third-party and are governed by | |
# separate terms of service, privacy policy, and support | |
# documentation. | |
name: GCM Release Build | |
on: | |
push: | |
paths-ignore: | |
- 'README.md' | |
- 'LICENSE' | |
branches: ["main"] | |
jobs: | |
release: | |
runs-on: ubuntu-latest | |
outputs: | |
gcm_version: ${{ steps.version-string.outputs.gcm_version }} | |
permissions: | |
contents: write | |
steps: | |
- name: Checkout GCM | |
uses: actions/checkout@v4 | |
- name: Set up JDK 17 | |
uses: actions/setup-java@v4 | |
with: | |
java-version: '17' | |
distribution: 'temurin' | |
server-id: central | |
server-username: MAVEN_USERNAME | |
server-password: MAVEN_PASSWORD | |
gpg-private-key: ${{ secrets.GPG_SECRET_KEY }} | |
gpg-passphrase: MAVEN_GPG_PASSPHRASE | |
- name: Build GCM | |
run: mvn clean deploy -Pjavadoc,sign --file pom.xml | |
env: | |
MAVEN_USERNAME: ${{ secrets.MAVEN_CENTRAL_USERNAME }} | |
MAVEN_PASSWORD: ${{ secrets.MAVEN_CENTRAL_TOKEN }} | |
MAVEN_GPG_PASSPHRASE: ${{ secrets.GPG_SECRET_KEY_PASSWORD }} | |
- name: Get GCM Version | |
id: version-string | |
run: | | |
echo "version=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout --file pom.xml)" >> "$GITHUB_ENV" | |
echo "gcm_version=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout --file pom.xml)" >> "$GITHUB_OUTPUT" | |
- name: Make Release | |
uses: ncipollo/release-action@v1 | |
with: | |
artifacts: "simulation/target/simulation-${{ env.version }}*" | |
name: "v${{ env.version }}" | |
tag: "v${{ env.version }}" | |
generateReleaseNotes: true | |
skipIfReleaseExists: true | |
update-gcm-taskit: | |
if: ${{ !endsWith(needs.release.outputs.gcm_version, '0') }} | |
needs: release | |
runs-on: ubuntu-latest | |
permissions: | |
contents: write | |
env: | |
VERSION: ${{ needs.release.outputs.gcm_version }} | |
steps: | |
- name: Checkout GCM Taskit | |
uses: actions/checkout@v4 | |
with: | |
repository: HHS/ASPR-ms-gcm-taskit | |
token: ${{ secrets.GHA_BOT }} | |
- name: Update GCM version | |
run : | | |
echo "$VERSION" | |
sed -i "0,/<gcm.version>.*<\/gcm.version>/s//<gcm.version>$VERSION<\/gcm.version>/g" pom.xml | |
- name: Increment GCM Taskit Version | |
run: | | |
current_version=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout --file pom.xml) | |
echo GCM Taskit Version: $current_version | |
parts=( ${current_version//./ } ) | |
bv=$((parts[2] + 1)) | |
new_version="${parts[0]}.${parts[1]}.${bv}" | |
echo New GCM Taskit Version: $new_version | |
sed -i "0,/<revision>.*<\/revision>/s//<revision>$new_version<\/revision>/g" pom.xml | |
- name: Setup Git | |
run: | | |
git config --global user.name "github-actions" | |
git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com" | |
- name: Make branch in GCM Taskit | |
run: | | |
git checkout -b update-gcm-to-$VERSION | |
git add pom.xml | |
git commit -m "Update gcm to $VERSION" | |
git push --set-upstream origin update-gcm-to-$VERSION | |
- name: Make PR in GCM Taskit | |
run: | | |
gh pr create -R HHS/ASPR-ms-gcm-taskit -B main --fill | |
gh pr merge -m --auto | |
env: | |
GH_TOKEN: ${{ secrets.GHA_BOT }} |