From e20e860c45cf94db57a09b1ad3f35cb27b2c7472 Mon Sep 17 00:00:00 2001 From: Yanbing Zhao Date: Sat, 29 Jul 2023 20:41:38 +0800 Subject: [PATCH] Add release workflow --- .github/workflows/release.yml | 75 ++++++++++++++++++++++++ gradle/wrapper/gradle-wrapper.properties | 2 +- 2 files changed, 76 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/release.yml diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 00000000..81cef974 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,75 @@ +name: release +on: + push: + tags: + - "**" +jobs: + publish: + runs-on: ubuntu-22.04 + steps: + - name: Checkout + uses: actions/checkout@v2 + with: + # Fetch all history + fetch-depth: 0 + - name: Setup Java 17 + uses: actions/setup-java@v2 + with: + distribution: 'temurin' + java-version: '17' + - name: Maven Publish + id: maven_publish + env: + ARCHIVE_URL: ${{ secrets.TEACON_ARCHIVE_URL }} + ARCHIVE_ENDPOINT: ${{ secrets.TEACON_ARCHIVE_ENDPOINT }} + ARCHIVE_ACCESS_KEY: ${{ secrets.TEACON_ARCHIVE_ACCESS_KEY }} + ARCHIVE_SECRET_KEY: ${{ secrets.TEACON_ARCHIVE_SECRET_KEY }} + run: ./gradlew -Dorg.gradle.s3.endpoint=$ARCHIVE_ENDPOINT publishReleasePublicationToTeaconRepository githubActionOutput + - name: Generate Changelog + id: changelog + shell: bash + env: + CURRENT: ${{ github.ref }} + # Special thanks to this post on Stack Overflow regarding change set between two tags: + # https://stackoverflow.com/questions/12082981 + # Do note that actions/checkout will enter detach mode by default, so you won't have + # access to HEAD ref. Use GitHub-Action-supplied `github.ref` instead. + # Special thanks to this issue ticket regarding escaping newline: + # https://github.com/actions/create-release/issues/25 + # We use Bash parameter expansion to do find-and-replace. + # https://www.gnu.org/software/bash/manual/html_node/Shell-Parameter-Expansion.html + # Also we cannot use git rev-list because it always prepend "commit " + # See https://stackoverflow.com/questions/36927089/ + run: | + current_tag=${CURRENT/refs\/tags\//} + last_tag=`git describe --tags --abbrev=0 "$current_tag"^ 2>/dev/null || echo` + if [ last_tag ]; then + changelog=`git log --pretty="format:%H: %s" ${last_tag}..$current_tag` + else + changelog=`git log --pretty="format:%H: %s"` + fi + changelog="${changelog//'%'/'%25'}" + changelog="${changelog//$'\n'/' %0A'}" + echo "::set-output name=value::Change set since ${last_tag:-the beginning}: %0A%0A$changelog" + - name: GitHub Release + id: create_release + uses: actions/create-release@v1.1.1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + tag_name: ${{ github.ref }} + release_name: ${{ github.ref }} + draft: false + prerelease: false + body: | + ${{ steps.changelog.outputs.value }} + - name: GitHub Release Artifact + uses: actions/upload-release-asset@v1.0.2 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + upload_url: ${{ steps.create_release.outputs.upload_url }} + asset_path: ${{ steps.maven_publish.outputs.artifact_path }} + asset_name: ${{ steps.maven_publish.outputs.artifact_publish_name }} + # https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/MIME_types/Common_types + asset_content_type: "application/java-archive" diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 0ad737d5..1f017e4e 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,5 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.1-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.1.1-all.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists