From 5930ca84a869ecc3745a3958c355e1c4e242d64b Mon Sep 17 00:00:00 2001 From: John Rayes Date: Sun, 17 Oct 2021 19:44:20 -0700 Subject: [PATCH] Update release-please.yml --- .github/workflows/release-please.yml | 41 ++++++++++++++++++++-------- 1 file changed, 29 insertions(+), 12 deletions(-) diff --git a/.github/workflows/release-please.yml b/.github/workflows/release-please.yml index 69eebe6..d8a5279 100644 --- a/.github/workflows/release-please.yml +++ b/.github/workflows/release-please.yml @@ -13,8 +13,7 @@ jobs: - uses: GoogleCloudPlatform/release-please-action@v2 id: release with: - token: ${{ secrets.GITHUB_TOKEN }} - release-type: simple + release-type: php package-name: ${{ env.MOD_NAME }} - uses: actions/github-script@v3 id: vars @@ -34,26 +33,44 @@ jobs: if: ${{ steps.release.outputs.pr && !steps.release.outputs.release_created }} - if: ${{ steps.release.outputs.pr && !steps.release.outputs.release_created }} run: | - version=$(cat ./version.txt) + version=$(cat ./composer.json | jq -r '.version') for f in src/*.php; do sed -i "/@version/c \ * @version $version" "$f" done sed -i "//c \ $version" src/package-info.xml - sed -i -E "1s/[0-9]+\.[0-9]+\.[0-9]+/$version/" src/readme.txt + sed -i -E "1s/[0-9]+\.[0-9]+\.[0-9]+/$version/" src/install.txt git config user.name github-actions[bot] git config user.email 41898282+github-actions[bot]@users.noreply.github.com git commit -am "build: Update versions in mod files" git push - uses: actions/checkout@v2 if: ${{ steps.release.outputs.release_created }} - - run: zip -r -j myfile.zip src/ + - run: tar -czvf myfile.tgz LICENSE README.md -C src $(ls src) if: ${{ steps.release.outputs.release_created }} - - uses: actions/upload-release-asset@v1 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + - name: Upload release asset + uses: actions/github-script@v2 with: - upload_url: ${{ steps.release.outputs.upload_url }} - asset_path: ./myfile.zip - asset_name: ${{ env.MOD_NAME }}_${{ steps.release.outputs.major }}-${{ steps.release.outputs.minor }}-${{ steps.release.outputs.patch }}.zip - asset_content_type: application/zip + script: | + const fs = require('fs'); + const release = await github.repos.getReleaseByTag({ + ...context.repo, + tag: "${{ steps.release.outputs.tag_name }}", + }); + await github.repos.uploadReleaseAsset({ + owner: context.repo.owner, + url: "${{ steps.release.outputs.upload_url }}", + repo: context.repo.repo, + headers: { + "content-type": "application/gzip", + "content-length": fs.statSync("./myfile.tgz").size + }, + name: "${{ env.MOD_NAME }}_${{ steps.release.outputs.major }}-${{ steps.release.outputs.minor }}-${{ steps.release.outputs.patch }}.tgz", + data: fs.readFileSync("./myfile.tgz") + }); + await github.repos.updateRelease({ + ...context.repo, + release_id: release.data.id, + draft: false, + name: "${{ steps.release.outputs.tag_name }}", + }); if: ${{ steps.release.outputs.release_created }}