-
Notifications
You must be signed in to change notification settings - Fork 439
138 lines (120 loc) · 5.4 KB
/
release.yml
File metadata and controls
138 lines (120 loc) · 5.4 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
name: Manual Release
on:
workflow_dispatch:
inputs:
bump:
description: 'Version bump type'
type: choice
options:
- major
- minor
- patch
- prerelease
required: false
release_version:
description: 'OR Explicit version number (must be greater than current root version)'
required: false
env:
NODE_VERSION: '24.11.1'
permissions:
contents: write
pull-requests: write
id-token: write
packages: write
jobs:
release:
# Allow only on master, spring*, summer*, winter*;
if: ${{ github.repository_owner == 'salesforce' }}
name: Release LWC - ${{ inputs.release_version }} ${{ inputs.bump }}
environment: release
runs-on: ubuntu-latest
steps:
- name: Validate input version
id: resolve_input
run: |
RELEASE_VERSION='${{ inputs.release_version }}'
if [ -z "$RELEASE_VERSION" ]; then
RELEASE_VERSION='${{ inputs.bump }}'
if [ -z "$RELEASE_VERSION" ]; then
echo "An explicit version number or release version type must be specified."
exit 1
fi
fi
if [ "$RELEASE_VERSION" = prerelease ]; then
TAG=canary
else
case "$GITHUB_REF_NAME" in
master) TAG=latest;;
winter*) TAG="$GITHUB_REF_NAME";;
spring*) TAG="$GITHUB_REF_NAME";;
summer*) TAG="$GITHUB_REF_NAME";;
*) echo "Could not determine tag for releasing $GITHUB_REF_NAME as v$NEW_VERSION." && exit 1;;
esac
fi
echo "Resolved input: $RELEASE_VERSION"
echo "resolved=$RELEASE_VERSION" >> "$GITHUB_OUTPUT"
echo "Resolved tag: $TAG"
echo "tag=$TAG" >> "$GITHUB_OUTPUT"
- name: Checkout
uses: actions/checkout@v5
with:
fetch-depth: 0
token: ${{ secrets.WORKFLOW_PAT }}
persist-credentials: true
- name: Setup Node
uses: actions/setup-node@v6
with:
node-version: ${{ env.NODE_VERSION }}
registry-url: 'https://registry.npmjs.org'
cache: 'yarn'
- name: Install dependencies
run: yarn install --frozen-lockfile --ignore-scripts # Building later; can skip for now
- name: Update LWC version
id: update_version
env:
VERSION_INPUT: ${{ steps.resolve_input.outputs.resolved }}
run: |
node ./scripts/release/version.js "$VERSION_INPUT"
RESOLVED_VERSION="$(jq -r .version package.json)"
echo "New version: $RESOLVED_VERSION"
echo "new_version=$RESOLVED_VERSION" >> "$GITHUB_OUTPUT"
- name: Build
run: yarn build
- name: Set git identity (Actions bot)
if: ${{ steps.resolve_input.outputs.resolved != 'prerelease' }}
run: |
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
- name: Commit & push
if: ${{ steps.resolve_input.outputs.resolved != 'prerelease' }}
uses: actions-js/push@v1.4
with:
github_token: ${{ secrets.WORKFLOW_PAT }}
branch: ${{ github.ref_name }}
message: 'chore: release v${{ steps.update_version.outputs.new_version }}'
- name: Publish to npm
env:
NEW_VERSION: ${{ steps.update_version.outputs.new_version }}
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
NPM_CONFIG_ALWAYS_AUTH: 'true'
TAG: ${{ steps.resolve_input.outputs.tag }}
run: |
# Force both npm and yarn to use npmjs and pick up the token
yarn config set registry https://registry.npmjs.org
npm config set registry https://registry.npmjs.org
printf "//registry.npmjs.org/:_authToken=${NODE_AUTH_TOKEN}\nalways-auth=true\n" > ~/.npmrc
# Sanity checks
echo "yarn registry: $(yarn config get registry)"
echo "npm registry: $(npm config get registry)"
echo "Publishing $GITHUB_REF_NAME as v$NEW_VERSION using tag $TAG."
yarn nx release publish --yes --tag "$TAG"
- name: Tag and create GitHub release
if: ${{ steps.resolve_input.outputs.resolved != 'prerelease' }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
VERSION: ${{ steps.update_version.outputs.new_version }}
run: |
git tag -a "v$VERSION" -m "Release v$VERSION"
git push origin tag "v$VERSION"
gh release create "v$VERSION" --title "v$VERSION" --generate-notes