Merge pull request #819 from alphagov/dependabot/maven/org.apache.mav… #362
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
name: Release to maven | |
on: | |
push: | |
branches: | |
- master | |
paths-ignore: | |
- '.github/**' | |
permissions: | |
contents: write | |
jobs: | |
check-signing-key: | |
uses: ./.github/workflows/_check_gpg_signing_key.yml | |
secrets: | |
GPG_PRIVATE_KEY: ${{ secrets.GPG_PRIVATE_KEY }} | |
release: | |
needs: check-signing-key | |
runs-on: ubuntu-latest | |
steps: | |
- name: Check out Git repository | |
uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab | |
- name: Install Java and Maven | |
uses: actions/setup-java@5ffc13f4174014e2d4d4572b3d74c3fa61aeb2c2 | |
with: | |
java-version: '11' | |
distribution: 'adopt' | |
- name: Cache Maven packages | |
uses: actions/cache@88522ab9f39a2ea568f7027eddc7d8d8bc9d59c8 | |
with: | |
path: ~/.m2 | |
key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }} | |
restore-keys: ${{ runner.os }}-m2 | |
- name: Set package version | |
id: set-package-version | |
run: | | |
PACKAGE_VERSION="1.0.$(date +"%Y%m%d%H%M%S")" | |
echo "PACKAGE_VERSION=$PACKAGE_VERSION" >> "$GITHUB_OUTPUT" | |
mvn versions:set -DnewVersion="$PACKAGE_VERSION" | |
- name: Release Maven package | |
uses: samuelmeuli/action-maven-publish@9001e5ada637a021e98c752a0b292c01151378b5 | |
with: | |
gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }} | |
gpg_passphrase: ${{ secrets.GPG_PASSPHRASE }} | |
nexus_username: ${{ secrets.MAVEN_USERNAME }} | |
nexus_password: ${{ secrets.MAVEN_PASSWORD }} | |
server_id: ossrh | |
- name: Create GitHub release | |
uses: actions/github-script@d7906e4ad0b1822421a7e6a35d5ca353c962f410 | |
with: | |
github-token: ${{ secrets.GITHUB_TOKEN }} | |
script: | | |
const releaseResponse = await github.rest.repos.createRelease({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
name: "Release ${{ steps.set-package-version.outputs.PACKAGE_VERSION }}", | |
tag_name: "${{ steps.set-package-version.outputs.PACKAGE_VERSION }}", | |
generate_release_notes: true, | |
}) | |
console.log(releaseResponse) |