1+ name : " (Tag): Prepare"
2+
3+ on :
4+ workflow_dispatch :
5+ inputs :
6+ version :
7+ description : ' Version to create the tag for (e.g. 3.6.9) or `next`'
8+ required : true
9+ type : string
10+ default : next
11+
12+ jobs :
13+ prepare-tag :
14+ runs-on : ubuntu-latest
15+ outputs :
16+ version : ${{ steps.version.outputs.version }}
17+ steps :
18+ - name : Checkout branch for release
19+ uses : actions/checkout@v4
20+
21+ - name : Set up Node.js
22+ uses : actions/setup-node@v4
23+ with :
24+ node-version-file : .node-version
25+
26+ - name : Install Dependencies & Configure Git
27+ run : |
28+ npm install
29+ git config user.name "code-snippets-bot"
30+ git config user.email "sre@codesnippets.pro"
31+
32+ - name : Get tag version
33+ id : version
34+ run : |
35+ if [ "${{ github.event.inputs.version }}" = "next" ]; then
36+ CURR=$(composer get-version)
37+ MAJOR=$(echo $CURR | cut -d. -f1)
38+ MINOR=$(echo $CURR | cut -d. -f2)
39+ PATCH=$(echo $CURR | cut -d. -f3)
40+ NEW_PATCH=$((PATCH+1))
41+ NEW_VERSION="$MAJOR.$MINOR.$NEW_PATCH"
42+ echo "version=$NEW_VERSION" >> $GITHUB_OUTPUT
43+ else
44+ echo "version=${{ github.event.inputs.version }}" >> $GITHUB_OUTPUT
45+ fi
46+
47+ - name : Create and switch to tag branch
48+ run : |
49+ git checkout -b "tag/v${{ steps.version.outputs.version }}"
50+
51+ - name : Prepare changelog
52+ if : false
53+ id : changelog
54+ uses : codesnippetspro/.github-private/.github/workflows/changelog.yml@main
55+
56+ - name : Apply changelog
57+ if : false
58+ run : echo "${{ steps.changelog.outputs.patch }}" | git apply -
59+
60+ - name : Commit changelog update
61+ run : |
62+ git ls-files --others --modified --exclude-standard | xargs git add
63+ git add -u
64+ git commit -m "chore(changelog): v${{ steps.version.outputs.version }}"
65+
66+ - name : Set new version
67+ run : |
68+ npm --no-git-tag-version version ${{ steps.version.outputs.version }}
69+
70+ - name : Commit version update
71+ run : |
72+ git ls-files --others --modified --exclude-standard | xargs git add
73+ git add -u
74+ git commit -m "chore(tag): v${{ steps.version.outputs.version }}"
75+
76+ - name : Push branch
77+ run : |
78+ git push --set-upstream origin "tag/v${{ steps.version.outputs.version }}"
79+
80+ - name : Open pull request
81+ env :
82+ GH_TOKEN : ${{ secrets.CS_GH_TOKEN }}
83+ run : |
84+ gh pr create --title 'chore(release): `v${{ steps.version.outputs.version }}`' --body 'Release `v${{ steps.version.outputs.version }}`' --base main --head "tag/v${{ steps.version.outputs.version }}"
0 commit comments