Skip to content

Publish a release

Publish a release #2

name: Publish a release
on:
workflow_dispatch:
env:
VERSION_FILE: gradle.properties
VERSION_EXTRACT_PATTERN: '(?<=VERSION_NAME=).+'
GH_USER_NAME: github.actor
GRADLE_OPTS: -Dorg.gradle.daemon=false -Dkotlin.incremental=false -Dorg.gradle.jvmargs="-Xmx4g -Xms512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8 -XX:MaxMetaspaceSize=1024m"
jobs:
publish_artifacts:
runs-on: macos-latest
steps:
- uses: actions/checkout@3df4ab11eba7bda6032a0b82a6bb43b11571feac # v4
with:
token: ${{ secrets.PUSH_PAT }}
- name: Generate versions
uses: HardNorth/[email protected]
with:
version-source: file
version-file: ${{ env.VERSION_FILE }}
version-file-extraction-pattern: ${{ env.VERSION_EXTRACT_PATTERN }}
- uses: actions/[email protected]
with:
distribution: 'zulu'
java-version-file: .ci-java-version
- uses: gradle/[email protected]
- name: Setup Gradle
uses: gradle/[email protected]
with:
gradle-version: wrapper
- name: Publish the artifacts
env:
ORG_GRADLE_PROJECT_mavenCentralUsername: ${{ secrets.SONATYPE_NEXUS_USERNAME }}
ORG_GRADLE_PROJECT_mavenCentralPassword: ${{ secrets.SONATYPE_NEXUS_PASSWORD }}
ORG_GRADLE_PROJECT_signingInMemoryKey: ${{ secrets.ARTIFACT_SIGNING_PRIVATE_KEY }}
run: ./gradlew publishAllPublicationsToMavenCentralRepository -Pversion=${{ env.RELEASE_VERSION }}
publish_release:
needs: publish_artifacts
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@3df4ab11eba7bda6032a0b82a6bb43b11571feac # v4
with:
token: ${{ secrets.PUSH_PAT }}
- uses: actions/[email protected]
with:
distribution: 'zulu'
java-version-file: .ci-java-version
- uses: gradle/[email protected]
- name: Setup Gradle
uses: gradle/[email protected]
with:
gradle-version: wrapper
- name: Generate versions
uses: HardNorth/[email protected]
with:
version-source: file
version-file: ${{ env.VERSION_FILE }}
version-file-extraction-pattern: ${{ env.VERSION_EXTRACT_PATTERN }}
- name: Create, checkout, and push release branch
run: |
git config user.name eygraber
git config user.email [email protected]
git checkout -b releases/${{ env.RELEASE_VERSION }}
git push origin releases/${{ env.RELEASE_VERSION }}
- name: Import GPG Key
uses: crazy-max/ghaction-import-gpg@82a020f1f7f605c65dd2449b392a52c3fcfef7ef # v6.0.0
with:
gpg_private_key: ${{ secrets.GIT_SIGNING_PRIVATE_KEY }}
passphrase: ${{ secrets.GIT_SIGNING_PRIVATE_KEY_PASSWORD }}
git_user_signingkey: true
git_commit_gpgsign: true
git_tag_gpgsign: true
- name: Store SHA of HEAD commit on ENV
run: echo "GIT_HEAD=$(git rev-parse HEAD)" >> $GITHUB_ENV
- name: Create tag
id: create_tag
uses: actions/github-script@v6
with:
github-token: ${{ secrets.PUSH_PAT }}
script: |
const {GIT_HEAD} = process.env
github.rest.git.createRef({
owner: context.repo.owner,
repo: context.repo.repo,
ref: "refs/tags/${{ env.RELEASE_VERSION }}",
sha: `${GIT_HEAD}`
})
- name: Build changelog
id: build_changelog
uses: mikepenz/release-changelog-builder-action@v4
with:
configuration: "changelog_config.json"
toTag: ${{ env.RELEASE_VERSION }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Create release
id: create_release
uses: ncipollo/[email protected]
with:
body: ${{ steps.build_changelog.outputs.changelog }}
name: Release ${{ env.RELEASE_VERSION }}
tag: ${{ env.RELEASE_VERSION }}
token: ${{ secrets.PUSH_PAT }}
- uses: actions/checkout@v4
with:
ref: ${{ github.event.head_ref }}
token: ${{ secrets.PUSH_PAT }}
- name: Prepare next dev version
id: prepare_next_dev
run: |
sed -i -e 's/${{ env.CURRENT_VERSION }}/${{ env.NEXT_VERSION }}/g' gradle.properties && \
sed -i -E -e 's/(jsonpathkt:|<version>)[0-9]+\.[0-9]+\.[0-9]+/\1${{ env.RELEASE_VERSION }}/g' README.md
- name: Commit next dev version
id: commit_next_dev
uses: EndBug/add-and-commit@v9
with:
add: "['gradle.properties', 'README.md']"
default_author: github_actions
message: "Prepare next dev version"