-
Notifications
You must be signed in to change notification settings - Fork 0
88 lines (74 loc) · 2.55 KB
/
release.yml
File metadata and controls
88 lines (74 loc) · 2.55 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
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