From 085918c4bfe3b749d6f4055b9a1953c207952dc5 Mon Sep 17 00:00:00 2001 From: kezhenxu94 Date: Fri, 21 Apr 2023 12:17:58 +0800 Subject: [PATCH] Add release workflow --- .github/workflows/Release.yaml | 71 ++++++++++++++++++++++++++++++++++ 1 file changed, 71 insertions(+) create mode 100644 .github/workflows/Release.yaml diff --git a/.github/workflows/Release.yaml b/.github/workflows/Release.yaml new file mode 100644 index 0000000..3d09a1a --- /dev/null +++ b/.github/workflows/Release.yaml @@ -0,0 +1,71 @@ +name: Release + +on: + push: + tags: + - v\d+\.\d+\.\d+ + +jobs: + Release: + name: Release + runs-on: ubuntu-latest + permissions: + contents: write + steps: + - name: Checkout source codes + uses: actions/checkout@v2 + with: + fetch-depth: 0 + - name: Setup Node + uses: actions/setup-node@v3 + with: + node-version: 10 + cache: npm + cache-dependency-path: yasa-ui/package-lock.json + - name: Setup Java + uses: actions/setup-java@v3 + with: + java-version: 11 + distribution: temurin + cache: maven + - name: Build + run: | + ./mvnw -B versions:set -DgenerateBackupPoms=false -DnewVersion=${GITHUB_REF_NAME#v} + ./mvnw -B clean package + - name: Upload Assets + id: uploaded-assets + uses: softprops/action-gh-release@v1 + with: + files: yasa-solr-plugin/target/yasa-solr-plugin-*.jar + - name: Sign Jar + id: sign-jar + run: | + cat < private-key.pem + ${{ secrets.SOLR_PACKAGE_SIGN_PRIVATE_KEY }} + EOF + sig=$(openssl dgst -sha1 -sign private-key.pem yasa-solr-plugin/target/yasa-solr-plugin-*.jar | openssl enc -base64 | tr -d \\n) + echo "sig=$sig" | tee -a $GITHUB_OUTPUT + - name: Update Repo + run: | + git reset --hard origin/master + git pull --rebase origin master + git config --global user.name "github-actions[bot]" + git config --global user.email "github-actions[bot]@users.noreply.github.com" + url=${{ fromJSON(steps.uploaded-assets.outputs.assets)[0].browser_download_url }} + sig=${{ steps.sign-jar.outputs.sig }} + jq '.[0].versions[.[0].versions | length] |= . + { + "version": '"\"${GITHUB_REF_NAME#v}"\"', + "date": '"\"$(date +%Y-%m-%d)\""', + "artifacts": [ + { + "url": '"\"$url\""', + "sig": '"\"$sig\""' + } + ] + }' repo/repository.json | tee repo/repository.json.tmp + mv repo/repository.json.tmp repo/repository.json + + git add repo/repository.json **/pom.xml + git commit -m "Update repository.json" + git push origin HEAD:master +