Create release #3
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: "Create release" | |
on: | |
workflow_dispatch: | |
env: | |
VERSION_FILE: gradle.properties | |
VERSION_PATTERN: '(?<=version=).+' | |
jobs: | |
version: | |
runs-on: ubuntu-latest | |
outputs: | |
CURRENT_VERSION: ${{ steps.versions.outputs.CURRENT_VERSION }} | |
NEXT_VERSION: ${{ steps.versions.outputs.NEXT_VERSION }} | |
RELEASE_VERSION: ${{ steps.versions.outputs.RELEASE_VERSION }} | |
steps: | |
- name: 'Checkout Repository' | |
uses: actions/checkout@v4 | |
- name: Get version | |
id: versions | |
uses: HardNorth/github-version-generate@v1.4.0 | |
with: | |
version-source: file | |
version-file: ${{ env.VERSION_FILE }} | |
version-file-extraction-pattern: ${{ env.VERSION_PATTERN }} | |
dump-unicode-data: | |
uses: ./.github/workflows/unicode-dump.yml | |
build-and-test: | |
needs: | |
- dump-unicode-data | |
uses: ./.github/workflows/build-and-test.yml | |
publish_artifacts: | |
needs: | |
- version | |
- build-and-test | |
runs-on: macos-latest | |
steps: | |
- name: 'Checkout Repository' | |
uses: actions/checkout@v4 | |
with: | |
submodules: true | |
- uses: actions/setup-java@v4 | |
with: | |
distribution: temurin | |
java-version-file: .java-version | |
- name: Validate Gradle Wrapper | |
uses: gradle/actions/wrapper-validation@v4 | |
- name: Cache konan | |
uses: actions/cache@v4 | |
with: | |
path: ~/.konan | |
key: ${{ runner.os }}-gradle-${{ hashFiles('*.gradle.kts') }} | |
restore-keys: | | |
${{ runner.os }}-gradle- | |
- name: Cache unicode data | |
uses: actions/cache@v4 | |
with: | |
enableCrossOsArchive: true | |
fail-on-cache-miss: true | |
path: unicode_dump | |
key: unicode-dump-${{ hashFiles('unicode_dump/*') }} | |
restore-keys: | | |
unicode-dump- | |
- name: Setup Gradle | |
uses: gradle/actions/setup-gradle@v4 | |
with: | |
gradle-version: wrapper | |
- name: Build and publish release | |
run: > | |
./gradlew --no-daemon --info :karacteristics:assemble | |
:karacteristics:publishAndReleaseToMavenCentral | |
-Pversion=${{ needs.version.outputs.RELEASE_VERSION }} | |
env: | |
ORG_GRADLE_PROJECT_signingInMemoryKeyId: ${{ secrets.SIGNING_KEY_ID }} | |
ORG_GRADLE_PROJECT_signingInMemoryKeyPassword: ${{ secrets.SIGNING_PASSWORD }} | |
ORG_GRADLE_PROJECT_signingInMemoryKey: ${{ secrets.SIGNING_SECRET_KEY }} | |
ORG_GRADLE_PROJECT_mavenCentralUsername: ${{ secrets.OSSRH_USERNAME }} | |
ORG_GRADLE_PROJECT_mavenCentralPassword: ${{ secrets.OSSRH_PASSWORD }} | |
ORG_GRADLE_PROJECT_RELEASE_SIGNING_ENABLED: true | |
create_release: | |
runs-on: ubuntu-latest | |
needs: | |
- publish_artifacts | |
- version | |
steps: | |
- name: 'Checkout Repository' | |
uses: actions/checkout@v4 | |
- 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/${{ needs.version.outputs.RELEASE_VERSION }}", | |
sha: `${GIT_HEAD}` | |
}) | |
- name: Build changelog | |
id: build_changelog | |
uses: mikepenz/release-changelog-builder-action@v5 | |
with: | |
toTag: ${{ needs.version.outputs.RELEASE_VERSION }} | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- name: Create release | |
id: create_release | |
uses: ncipollo/release-action@v1.14.0 | |
with: | |
body: ${{ steps.build_changelog.outputs.changelog }} | |
name: Release ${{ needs.version.outputs.RELEASE_VERSION }} | |
tag: ${{ needs.version.outputs.RELEASE_VERSION }} | |
token: ${{ secrets.PUSH_PAT }} | |
makeLatest: ${{ github.ref == 'refs/heads/main' }} | |
update-version: | |
runs-on: ubuntu-latest | |
needs: | |
- create_release | |
- version | |
steps: | |
- name: 'Checkout Repository' | |
uses: actions/checkout@v4 | |
with: | |
token: ${{ secrets.PUSH_PAT }} | |
- name: Prepare next dev version | |
id: prepare_next_dev | |
run: | | |
sed -i -e 's/${{ needs.version.outputs.CURRENT_VERSION }}/${{ needs.version.outputs.NEXT_VERSION }}/g' gradle.properties | |
sed -i -E -e 's/karacteristics(:|\/)[0-9]+\.[0-9]+\.[0-9]+/karacteristics\1${{ needs.version.outputs.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 version" |