Skip to content

Merge pull request #82 from helsingborg-stad/chore/update-lang #82

Merge pull request #82 from helsingborg-stad/chore/update-lang

Merge pull request #82 from helsingborg-stad/chore/update-lang #82

Workflow file for this run

name: Bump version, build and create release
on:
push:
branches:
- main
jobs:
release:
runs-on: ubuntu-latest
permissions:
contents: write
packages: write
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Bump version files (no release yet)
uses: helsingborg-stad/release-wp-plugin-action@main
with:
php-version: 8.2
node-version: 20.6.0
skip-release: true # custom flag you added
- name: Pull latest main with bumped version
run: |
git fetch origin main
git checkout main
git pull origin main
- name: Extract version
id: version
run: |
VERSION=$(jq -r '.version' package.json)
echo "version=$VERSION" >> $GITHUB_OUTPUT
echo "Detected version: $VERSION"
# --- PHP Build ---
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: "8.2"
- name: Configure npm for GitHub Packages
run: |
echo "//npm.pkg.github.com/:_authToken=${{ secrets.GITHUB_TOKEN }}" > ~/.npmrc
echo "@helsingborg-stad:registry=https://npm.pkg.github.com" >> ~/.npmrc
- name: Run PHP build script
run: php build.php --no-composer --cleanup --release
- name: Overwrite .gitignore for release branch
run: |
printf "/*\n!/dist\n!/dist/**\n!/source/php\n!/source/php/**\n!/assets\n!/assets/**" > .gitignore
# --- Release Branch Commit ---
- name: Commit and push release branch
run: |
git config user.name "CI Release Bot"
git config user.email "ci@helsingborg.se"
git checkout -B release
git add -A
git commit -m "Release build from $GITHUB_SHA" || echo "No changes to commit"
git push origin release --force
# --- Tag and create GitHub Release on release branch ---
- name: Create and push tag
run: |
TAG="${{ steps.version.outputs.version }}"
# skip if tag already exists
if git ls-remote --tags origin | grep -q "refs/tags/$TAG$"; then
echo "Tag $TAG already exists, skipping tag creation."
exit 0
fi
git tag "$TAG"
git push origin "$TAG"
- name: Wait for tag propagation
run: sleep 5
- name: Create GitHub Release
uses: ncipollo/release-action@v1
with:
tag: ${{ steps.version.outputs.version }}
generateReleaseNotes: true