-
Notifications
You must be signed in to change notification settings - Fork 2.2k
80 lines (71 loc) · 2.56 KB
/
release-preid.yml
File metadata and controls
80 lines (71 loc) · 2.56 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
name: Release Preid
# Concurrency control to prevent multiple preid releases running simultaneously
# Cancels in-progress releases when new commits are pushed
concurrency:
group: push-release-${{ github.ref }}
cancel-in-progress: true
# Permissions required for publishing packages
permissions:
contents: write
on:
push:
branches:
# Branch naming pattern: feat/{PREID}/whatever
# Example: feat/alpha/main, feat/beta/my-feature, feat/rc/test
- feat/preid/whatever
jobs:
# Job 1: Parse preid from branch name
parse-preid:
name: Parse preid from branch
runs-on: ubuntu-latest
env:
BRANCH: ${{ github.ref_name }}
outputs:
preid: ${{ steps.output_preid.outputs.preid }}
steps:
- id: output_preid
run: |
PREID=$(echo $BRANCH | tr -cd '[:alnum:]_\-/.' | cut -d \/ -f 2)
echo "preid=$PREID" >> $GITHUB_OUTPUT
echo "Extracted preid from branch: $PREID"
# Job 2: Validate preid against forbidden list
validate-preid:
runs-on: ubuntu-latest
needs: parse-preid
steps:
- name: Validate preid
env:
PREID: ${{ needs.parse-preid.outputs.preid }}
FORBIDDEN_PREIDS: latest next unstable stable-5 stable-4
run: |
echo "Testing to see if $PREID is in the forbidden list ($FORBIDDEN_PREIDS)"
# Convert to lowercase for case-insensitive comparison (npm tags are case-insensitive)
PREID_LOWER=$(echo "$PREID" | tr '[:upper:]' '[:lower:]')
for e in $FORBIDDEN_PREIDS; do
[[ "$PREID_LOWER" == "$e" ]] && echo "ERROR: $PREID is forbidden from preid release" && exit 1
done
echo "SUCCESS: $PREID is allowed for preid release"
# Job 3: Publish prerelease packages
preid-release:
runs-on: ubuntu-latest
needs:
- parse-preid
- validate-preid
if: github.repository_owner == 'aws-amplify'
steps:
- name: Checkout repository
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
path: amplify-js
- name: Setup node and build the repository
uses: ./amplify-js/.github/actions/node-and-build
- name: Publish to @preid
uses: changesets/action@aba318e9165b45b7948c60273e0b72fce0a64eb9 # v1.4.7
with:
cwd: ./amplify-js
publish: yarn publish:preid
createGithubReleases: false
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
PREID: ${{ needs.parse-preid.outputs.preid }}