Release action fix #patch #7
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: tag-release | |
on: | |
push: | |
branches: | |
- main | |
jobs: | |
tag: | |
runs-on: ubuntu-latest | |
permissions: | |
contents: write | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: "0" | |
- name: Bump version and push tag | |
id: tag | |
uses: anothrNick/[email protected] | |
env: | |
WITH_V: true | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
DEFAULT_BUMP: none | |
RELEASE_BRANCHES: main | |
outputs: | |
bump: ${{ steps.tag.outputs.part }} | |
new_tag: ${{ steps.tag.outputs.new_tag }} | |
release: | |
runs-on: ubuntu-latest | |
permissions: | |
contents: write | |
needs: tag | |
if: needs.tag.outputs.bump != '' && needs.tag.outputs.bump != 'none' | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- uses: pnpm/action-setup@v2 | |
with: | |
version: 9 | |
- name: Setup PHP | |
uses: shivammathur/setup-php@v2 | |
with: | |
php-version: 8.3 | |
extensions: dom, curl, libxml, mbstring, zip | |
ini-values: error_reporting=E_ALL | |
tools: composer:v2 | |
coverage: none | |
- name: Cache composer vendor files | |
id: cache-composer | |
uses: actions/cache@v3 | |
env: | |
cache-name: cache-composer | |
with: | |
path: /vendor | |
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/composer.lock') }} | |
- name: Update version in PHP file | |
run: | | |
VERSION=${{ needs.tag.outputs.new_tag }} | |
VERSION=${VERSION#v} | |
sed -i "s/Version: .*/Version: $VERSION/" inertia-wordpress.php | |
- name: Install dependencies | |
uses: nick-fields/retry@v3 | |
with: | |
timeout_minutes: 1 | |
max_attempts: 5 | |
command: composer install --no-interaction | |
- name: Use Node.js 22 | |
uses: actions/setup-node@v4 | |
with: | |
node-version: 22 | |
cache: "pnpm" | |
- run: pnpm -r install | |
- name: Process changelog | |
id: changelog_file | |
run: | | |
if [[ ! -z $(cat changelog/next.md) ]] ; then | |
echo "changelog=${{ needs.tag.outputs.new_tag }}-$(date +'%Y-%m-%d')" >> $GITHUB_OUTPUT | |
mv changelog/next.md changelog/${{ needs.tag.outputs.new_tag }}-$(date +'%Y-%m-%d').md | |
touch changelog/next.md | |
else | |
echo "changelog=next" >> $GITHUB_OUTPUT | |
fi | |
- name: Build assets | |
run: pnpm -r run build | |
- name: Commit changes to changelog folder | |
continue-on-error: true | |
run: | | |
git config --global user.email "[email protected]" | |
git config --global user.name "evoMark Action" | |
git add changelog/ inertia-wordpress.php | |
git commit -m "Chore: Updated changelog" | |
git push | |
- name: Create ZIP for release | |
run: | | |
mkdir -p temp_inertia-wordpress | |
rsync -a --exclude-from=exclude.txt . temp_inertia-wordpress/ | |
mv temp_inertia-wordpress inertia-wordpress | |
zip -r inertia-wordpress.zip inertia-wordpress | |
rm -rf inertia-wordpress | |
- name: Create Github release | |
id: create_release | |
uses: softprops/action-gh-release@v2 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
tag_name: ${{ needs.tag.outputs.new_tag }} | |
name: ${{ needs.tag.outputs.new_tag }} | |
body_path: changelog/${{ steps.changelog_file.outputs.changelog }}.md | |
draft: false | |
prerelease: false | |
files: inertia-wordpress.zip |