Publish a release #10
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: Publish a release | |
on: | |
workflow_dispatch: | |
env: | |
VERSION_FILE: gradle.properties | |
VERSION_EXTRACT_PATTERN: '(?<=version=).+' | |
GH_USER_NAME: github.actor | |
GRADLE_OPTS: -Dorg.gradle.daemon=false -Dkotlin.incremental=false -Dorg.gradle.jvmargs="-Xmx16g -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8 -XX:MaxMetaspaceSize=1024m" | |
jobs: | |
publish_artifacts: | |
runs-on: macos-latest | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
token: ${{ secrets.PUSH_PAT }} | |
- name: Generate versions | |
uses: HardNorth/github-version-generate@v1 | |
with: | |
version-source: file | |
version-file: ${{ env.VERSION_FILE }} | |
version-file-extraction-pattern: ${{ env.VERSION_EXTRACT_PATTERN }} | |
- uses: actions/setup-java@v4 | |
with: | |
distribution: 'zulu' | |
java-version-file: .ci-java-version | |
- name: Setup Gradle | |
uses: gradle/actions/setup-gradle@v4 | |
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@v4 | |
with: | |
token: ${{ secrets.PUSH_PAT }} | |
- name: Generate versions | |
uses: HardNorth/github-version-generate@v1 | |
with: | |
version-source: file | |
version-file: ${{ env.VERSION_FILE }} | |
version-file-extraction-pattern: ${{ env.VERSION_EXTRACT_PATTERN }} | |
- uses: actions/setup-java@v4 | |
with: | |
distribution: 'zulu' | |
java-version-file: .ci-java-version | |
- 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@v6 | |
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@v7 | |
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@v5 | |
with: | |
configuration: "changelog_config.json" | |
toTag: ${{ env.RELEASE_VERSION }} | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- name: Create release | |
id: create_release | |
uses: ncipollo/release-action@v1 | |
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/vice-core(:|\/)[0-9]+\.[0-9]+\.[0-9]+/vice-core\1${{ env.RELEASE_VERSION }}/g' README.md && \ | |
sed -i -E -e 's/vice-nav(:|\/)[0-9]+\.[0-9]+\.[0-9]+/vice-nav\1${{ env.RELEASE_VERSION }}/g' README.md | |
- name: Update package-lock.json if needed | |
run: ./gradlew kotlinUpgradePackageLock --no-build-cache --no-configuration-cache --rerun-tasks | |
- name: Commit next dev version | |
id: commit_next_dev | |
uses: EndBug/add-and-commit@v9 | |
with: | |
add: "['gradle.properties', 'README.md', 'kotlin-js-store/package-lock.json']" | |
default_author: github_actions | |
message: "Prepare next dev version" |