-
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
148 lines (133 loc) Β· 4.76 KB
/
release.yml
File metadata and controls
148 lines (133 loc) Β· 4.76 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
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
# Publishes GH release for new versions, with compiled app attached
# - Triggered when a git tag matching X.Y.0 (major or minor) is pushed
# - Or if manually dispatched with any valid and existing tag specified
# - Check out the source at the requested tag
# - Run a clean production build (yarn build β dist/)
# - Bundle dist/ + server.js + package.json + yarn.lock into tar.gz and zip
# - Create a DRAFT GH release with auto-gen changelog and bundled artifacts attached
name: π Release
on:
push:
tags:
- '*.*.0'
workflow_dispatch:
inputs:
tag:
description: 'Existing git tag to release (e.g. 2.1.0)'
required: true
type: string
permissions:
contents: write
concurrency:
group: release-${{ inputs.tag || github.ref_name }}
cancel-in-progress: false
jobs:
release:
name: π Build & Publish Release
runs-on: ubuntu-latest
steps:
- name: Resolve tag π·οΈ
id: tag
env:
INPUT_TAG: ${{ inputs.tag }}
EVENT_NAME: ${{ github.event_name }}
REF: ${{ github.ref }}
run: |
if [ "$EVENT_NAME" = "workflow_dispatch" ]; then
TAG="$INPUT_TAG"
else
TAG="${REF#refs/tags/}"
fi
if ! echo "$TAG" | grep -qE '^[0-9]+\.[0-9]+\.[0-9]+$'; then
echo "::error::Invalid tag '$TAG'. Expected semver (e.g. 2.1.0)."
exit 1
fi
echo "tag=$TAG" >> "$GITHUB_OUTPUT"
echo "Releasing tag: $TAG"
- name: Checkout source at tag ποΈ
uses: actions/checkout@v6
with:
ref: refs/tags/${{ steps.tag.outputs.tag }}
fetch-depth: 0
- name: Setup Node.js π§
uses: actions/setup-node@v6
with:
node-version: '22'
cache: 'yarn'
- name: Install dependencies π¦
run: yarn install --frozen-lockfile
- name: Build for production ποΈ
run: yarn build
- name: Verify build output β
run: |
if [ ! -d "dist/client" ]; then
echo "::error::Build failed: dist/client directory not created"
exit 1
fi
if [ ! -f "dist/server/entry.mjs" ]; then
echo "::error::Build failed: SSR entry not found"
exit 1
fi
echo "β
Build successful"
- name: Package release artifacts ποΈ
id: package
env:
TAG: ${{ steps.tag.outputs.tag }}
run: |
STAGING="web-check-${TAG}"
rm -rf "$STAGING"
mkdir -p "$STAGING"
cp -r dist api public "$STAGING/"
cp server.js package.json yarn.lock "$STAGING/"
[ -f LICENSE ] && cp LICENSE "$STAGING/" || true
[ -f README.md ] && cp README.md "$STAGING/" || true
TARBALL="${STAGING}.tar.gz"
ZIPFILE="${STAGING}.zip"
tar -czf "$TARBALL" "$STAGING"
zip -qr "$ZIPFILE" "$STAGING"
ls -lh "$TARBALL" "$ZIPFILE"
echo "tarball=$TARBALL" >> "$GITHUB_OUTPUT"
echo "zipfile=$ZIPFILE" >> "$GITHUB_OUTPUT"
- name: Create draft release π
id: release
uses: softprops/action-gh-release@v3
with:
tag_name: ${{ steps.tag.outputs.tag }}
name: Web-Check v${{ steps.tag.outputs.tag }}
draft: true
prerelease: false
generate_release_notes: true
fail_on_unmatched_files: true
files: |
${{ steps.package.outputs.tarball }}
${{ steps.package.outputs.zipfile }}
token: ${{ secrets.BOT_TOKEN || secrets.GITHUB_TOKEN }}
- name: Job summary π
if: always()
env:
TAG: ${{ steps.tag.outputs.tag }}
REPO_URL: ${{ github.server_url }}/${{ github.repository }}
RELEASE_URL: ${{ steps.release.outputs.url }}
RELEASE_OUTCOME: ${{ steps.release.outcome }}
run: |
{
echo "## π Release"
echo ""
echo "| Step | Result |"
echo "|------|--------|"
if [ -n "$TAG" ]; then
echo "| Tag | [\`${TAG}\`](${REPO_URL}/releases/tag/${TAG}) |"
else
echo "| Tag | β Could not resolve |"
fi
if [ "$RELEASE_OUTCOME" = "success" ]; then
if [ -n "$RELEASE_URL" ]; then
echo "| Draft release | β
[View draft](${RELEASE_URL}) |"
else
echo "| Draft release | β
[View releases](${REPO_URL}/releases) |"
fi
echo "| Artifacts | \`web-check-${TAG}.tar.gz\`, \`web-check-${TAG}.zip\` |"
else
echo "| Draft release | β Failed (outcome: ${RELEASE_OUTCOME:-unknown}) |"
fi
} >> "$GITHUB_STEP_SUMMARY"