Prepare for publishing 2.7.2 #73
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: Git Branch Publish | |
# Publish artifacts to a Git branch, which can be added as a Maven repository | |
on: | |
workflow_dispatch: | |
push: | |
branches: | |
- main | |
concurrency: | |
group: "${{ github.workflow }}" | |
cancel-in-progress: false | |
env: | |
# get the current branch name https://stackoverflow.com/a/71158878/4161471 | |
CURRENT_BRANCH_NAME: ${{ github.head_ref || github.ref_name }} | |
jobs: | |
create-m2-publication: | |
runs-on: macos-latest # macOS can publish all Kotlin targets | |
environment: | |
name: artifacts | |
url: ${{ steps.deployment.outputs.page_url }} | |
timeout-minutes: 60 | |
steps: | |
- name: checkout repo | |
uses: actions/checkout@v4 | |
with: | |
ref: ${{ env.CURRENT_BRANCH_NAME }} | |
- name: setup JDK | |
uses: actions/setup-java@v4 | |
with: | |
distribution: temurin | |
java-version: 11 | |
- uses: gradle/gradle-build-action@v2 | |
with: | |
gradle-home-cache-cleanup: true | |
- name: Run publish task | |
run: >- | |
./gradlew publishAllPublicationsToGitBranchPublishRepository --stacktrace --info | |
env: | |
GIT_BRANCH_PUBLISH_DIR: ${{ runner.temp }}/m2 | |
- name: upload build reports | |
if: failure() | |
uses: actions/upload-artifact@v4 | |
with: | |
name: build-report-${{ runner.os }}-${{ github.action }} | |
path: "**/build/reports/" | |
if-no-files-found: ignore | |
- name: upload local project publication | |
uses: actions/upload-artifact@v4 | |
with: | |
name: m2-publication | |
path: ${{ env.GIT_BRANCH_PUBLISH_DIR }} | |
env: | |
GIT_BRANCH_PUBLISH_DIR: ${{ runner.temp }}/m2 | |
commit-artifacts: | |
runs-on: ubuntu-latest | |
needs: create-m2-publication | |
environment: | |
name: artifacts | |
url: https://github.com/krzema12/snakeyaml-engine-kmp/tree/artifacts/m2 | |
env: | |
CI_COMMIT_MESSAGE: artifacts | |
CI_COMMIT_AUTHOR: ${{ github.workflow }} | |
steps: | |
- name: Checkout artifacts branch | |
uses: actions/checkout@v4 | |
with: | |
ref: artifacts | |
- name: download local project publication | |
uses: actions/download-artifact@v4 | |
with: | |
name: m2-publication | |
path: m2 | |
- name: git push | |
run: | | |
git config --global user.name "${{ env.CI_COMMIT_AUTHOR }}" | |
git config --global user.email "[email protected]" | |
git add . | |
git commit -a -m "${{ env.CI_COMMIT_MESSAGE }}" | |
git push |