-
Notifications
You must be signed in to change notification settings - Fork 87
126 lines (112 loc) · 4.36 KB
/
release.yml
File metadata and controls
126 lines (112 loc) · 4.36 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
name: Release
on:
workflow_dispatch:
inputs:
version_type:
description: "The type of version bump to perform (patch, minor, major, prepatch, preminor, premajor, test)"
required: true
type: choice
options:
- patch
- test
- minor
- major
- prepatch
- preminor
- premajor
preid:
description: "Prerelease identifier (e.g., alpha, beta, rc). Used with prepatch/preminor/premajor."
required: false
default: "alpha"
create_gh_release:
description: "If true, creates a GitHub release with auto-generated notes."
required: false
type: boolean
default: true
force_gh_release_for_test:
description: "If true, forces creation of a GitHub release even for a 'test' version."
required: false
type: boolean
default: false
permissions:
contents: write
env:
CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}
jobs:
release:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
# We need to fetch all history for semver to work correctly and to push changes.
fetch-depth: 0
# This token should have write permissions to the repository.
# It's recommended to use a dedicated bot account's PAT.
# The secret should be named GH_TOKEN_FOR_RELEASES
token: ${{ secrets.GH_TOKEN_FOR_RELEASES }}
- name: Set up Git user
run: |
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 22
- name: Install dependencies
run: |
corepack enable
pnpm install
- name: Setup .npmrc for publishing
working-directory: sdk
run: |
echo "//registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }}" > .npmrc
echo "registry=https://registry.npmjs.org/" >> .npmrc
echo "always-auth=true" >> .npmrc
- name: Run release script
id: release_script
working-directory: sdk
run: |
COMMAND="./scripts/release.sh ${{ github.event.inputs.version_type }}"
if [[ "${{ github.event.inputs.version_type }}" == "pre"* ]]; then
COMMAND="$COMMAND --preid ${{ github.event.inputs.preid }}"
fi
echo "Running command: $COMMAND"
eval $COMMAND
- name: Create GitHub Release
if: >
success() &&
(github.event.inputs.version_type != 'test' || github.event.inputs.force_gh_release_for_test == 'true') &&
github.event.inputs.create_gh_release == 'true'
env:
GH_TOKEN: ${{ secrets.GH_TOKEN_FOR_RELEASES }}
run: |
FLAGS="--generate-notes"
VERSION_TYPE="${{ github.event.inputs.version_type }}"
if [[ "$VERSION_TYPE" == "patch" || "$VERSION_TYPE" == "minor" || "$VERSION_TYPE" == "major" ]]; then
FLAGS="$FLAGS --latest"
elif [[ "$VERSION_TYPE" == "pre"* ]]; then
FLAGS="$FLAGS --prerelease"
fi
echo "Creating GitHub release for tag ${{ env.TAG_NAME }} with flags: $FLAGS"
gh release create ${{ env.TAG_NAME }} $FLAGS
- name: Prune node_modules for artifact upload
if: failure() && steps.release_script.outputs.project-dir
run: |
echo "Pruning node_modules to reduce artifact size..."
find ${{ steps.release_script.outputs.project-dir }}/node_modules -mindepth 1 -maxdepth 1 -not -name "rwsdk" -exec rm -rf {} +
echo "Pruning complete."
- name: Upload logs on failure
if: failure() && steps.release_script.outputs.project-dir
uses: actions/upload-artifact@v4
with:
name: smoke-test-failure-logs
path: ${{ steps.release_script.outputs.project-dir }}
- name: Upload smoke test artifacts
if: always() && steps.release_script.outputs.project-dir
uses: actions/upload-artifact@v4
with:
name: release-smoke-test-artifacts
path: ${{ steps.release_script.outputs.project-dir }}/artifacts
retention-days: 7