Skip to content

Update release-please.yml #113

Update release-please.yml

Update release-please.yml #113

on:
push:
branches:
- master
name: release-please
jobs:
release-please:
runs-on: ubuntu-latest
env:
FORCE_COLOR: 1
MOD_NAME: custom-forms
steps:
- uses: googleapis/release-please-action@v4
id: release
with:
release-type: php
draft: true
package-name: ${{ env.MOD_NAME }}
- uses: actions/checkout@v4
with:
ref: ${{ fromJson(steps.release.outputs.pr).headBranchName }}
if: ${{ steps.release.outputs.pr && !steps.release.outputs.release_created }}
- if: ${{ steps.release.outputs.pr && !steps.release.outputs.release_created }}
run: |
VERSION=$(cat ./composer.json | jq -r '.version')
RE='[^0-9]*\([0-9]*\)[.]\([0-9]*\)[.]\([0-9]*\)\([0-9A-Za-z-]*\)'
MAJOR=`echo $VERSION | sed -e "s#$RE#\1#"`
MINOR=`echo $VERSION | sed -e "s#$RE#\2#"`
PATCH=`echo $VERSION | sed -e "s#$RE#\3#"`
shopt -s globstar
for f in src/**/*.php; do
sed -i "/@version/c \ * @version $VERSION" "$f"
done
sed -i "/<version>/c \ <version>$VERSION</version>" src/package-info.xml
sed -i -E "30s/[0-9]+\.[0-9]+\.[0-9]+/$VERSION/" src/CustomForm/ManageCustomForm.php
sed -i -E "1s/[0-9]+\.[0-9]+\.[0-9]+/$VERSION/" src/install.txt
sed -i -E "10s/[0-9]+\.[0-9]+\.[0-9]+/$VERSION/g" README.md
sed -i -E "10s/[0-9]+-[0-9]+-[0-9]+/${MAJOR}-${MINOR}-${PATCH}/" README.md
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@v4
if: ${{ steps.release.outputs.release_created }}
- run: tar -czvf myfile.tgz LICENSE README.md -C src $(ls src)
if: ${{ steps.release.outputs.release_created }}
- name: Upload release asset
uses: actions/github-script@v7
with:
script: |
const fs = require('fs');
const str = "${{ steps.release.outputs.upload_url }}";
await github.rest.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.rest.repos.updateRelease({
...context.repo,
release_id: str.substring(str.lastIndexOf('/', str.lastIndexOf('/assets') - 1) + 1, str.lastIndexOf('/assets')),
draft: false,
name: "${{ steps.release.outputs.tag_name }}",
});
if: ${{ steps.release.outputs.release_created }}