-
-
Notifications
You must be signed in to change notification settings - Fork 397
134 lines (113 loc) · 4.04 KB
/
releases.yml
File metadata and controls
134 lines (113 loc) · 4.04 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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
name: manual release
on:
workflow_dispatch:
inputs:
version:
description: 'Version to release'
required: true
latest:
description: 'Mark as latest release?'
required: true
default: 'true'
type: choice
options:
- 'true'
- 'false'
prerelease:
description: 'Is this a pre-release?'
required: true
default: 'false'
type: choice
options:
- 'true'
- 'false'
permissions:
contents: write
jobs:
release:
runs-on: ubuntu-24.04
name: Release ${{ inputs.version }}
outputs:
version: ${{ steps.version.outputs.version }}
notes: ${{ steps.cleaned-notes.outputs.notes }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
token: ${{ secrets.RELEASE_GITHUB_TOKEN }}
- name: Remove optional "v" prefix
id: version
run: |
echo "version=${VERSION#v}" >> "$GITHUB_OUTPUT"
env:
VERSION: ${{ inputs.version }}
- name: Check if branch and version match
id: guard
run: |
MAJOR_VERSION="${NUMERIC_VERSION%%.*}"
BRANCH_MAJOR_VERSION="${BRANCH%%.*}"
if [ "$MAJOR_VERSION" != "$BRANCH_MAJOR_VERSION" ]; then
echo "Mismatched versions! Aborting."
VERSION_MISMATCH='true';
else
echo "Versions match! Proceeding."
VERSION_MISMATCH='false';
fi
echo "VERSION_MISMATCH=$(echo $VERSION_MISMATCH)" >> "$GITHUB_OUTPUT";
env:
BRANCH: ${{ github.ref_name }}
NUMERIC_VERSION: ${{ steps.version.outputs.version }}
- name: Fail if branch and release tag do not match
if: ${{ steps.guard.outputs.VERSION_MISMATCH == 'true' }}
uses: actions/github-script@v7
with:
script: |
core.setFailed('Workflow failed. Release version does not match with selected target branch. Did you select the correct branch?')
- name: Update config/app.php
run: sed -i "s/'version' => '[^']*'/'version' => '${{ steps.version.outputs.version }}'/" config/app.php
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: "22.x"
- name: Install NPM Dependencies
run: npm install --force
- name: Build assets
run: npm run build
# Release
- name: Commit changes
uses: stefanzweifel/git-auto-commit-action@v5
with:
commit_message: "Build version ${{ steps.version.outputs.version }}"
- name: Create release
uses: softprops/action-gh-release@v2
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ steps.version.outputs.version }}
name: ${{ steps.version.outputs.version }}
body: ${{ steps.cleaned-notes.outputs.notes }}
target_commitish: ${{ github.ref_name }}
make_latest: ${{ inputs.latest == 'true' }}
prerelease: ${{ inputs.prerelease == 'true' }}
generate_release_notes: true
- name: Verify GitHub CLI
run: gh --version
- name: Get release notes from GitHub API
id: fetch-release
run: |
NOTES=$(gh release view ${{ steps.version.outputs.version }} --json body -q .body)
echo "notes<<EOF" >> $GITHUB_OUTPUT
echo "$NOTES" >> $GITHUB_OUTPUT
echo "EOF" >> $GITHUB_OUTPUT
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Send release notes to Discord
run: |
DISCORD_MESSAGE=$(printf "**VitoDeploy ${{ steps.version.outputs.version }}** is out! 🎉🚀\n\`\`\`\n%s\n\`\`\`" "${{ steps.fetch-release.outputs.notes }}")
PAYLOAD=$(jq -n --arg content "$DISCORD_MESSAGE" '{content: $content}')
curl -H "Content-Type: application/json" \
-X POST \
-d "$PAYLOAD" \
"$DISCORD_WEBHOOK_URL"
env:
DISCORD_WEBHOOK_URL: ${{ secrets.DISCORD_WEBHOOK_URL }}