-
Notifications
You must be signed in to change notification settings - Fork 7
132 lines (116 loc) · 4.21 KB
/
release.yml
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
name: Release
# triggers on pushes to the 'prod' branch
on:
push:
# NOTE(thuang): Since REGEX is not supported for branches, we cannot target
# any versioned branch: "+([0-9])?(.{+([0-9]),x}).x" as specified in
# .releaserc.js. So we'll need to manually add such branch's name here manually
branches:
- prod
jobs:
# Job 1
release:
name: Release
runs-on: ubuntu-latest # Use the latest version of the Ubuntu runner environment
steps:
# Step 1: Check out the repository code
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
# Step 2: Set up Node.js environment and cache Yarn dependencies
- name: Setup Node.js and Cache yarn
uses: actions/setup-node@v3
with:
node-version-file: ".node-version" # Specify the Node.js version from '.node-version' file
cache: "yarn" # Cache Yarn dependencies for faster builds
# Step 3: Set up npm and authentication
- name: "Setup npm"
run: |
npm set "//registry.npmjs.org/:_authToken=${NODE_AUTH_TOKEN}"
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
# Step 4: Ensure npm access
- name: Ensure NPM access
run: npm whoami
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
# Step 5: Install project dependencies using Yarn
- name: Install dependencies
run: yarn ci
# Step 6: Build the component library in 'dist/' directory
- name: Build component library in dist/
run: yarn build
# Step 7: Configure git user for pushing release changes back to prod branch
- name: Config git user
run: |
git config --global user.name "${{ github.actor }}"
git config --global user.email "${{ github.actor }}@users.noreply.github.com"
# Step 8: Lerna Version
- name: Lerna Version
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
run: yarn version:ci
# Step 9: Commit changes
- name: Commit changes
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
uses: stefanzweifel/git-auto-commit-action@v4
with:
commit_message: "chore(release): Publish"
branch: ${{ github.head_ref }}
# Step 10: Publish NPM packages
- name: Lerna Publish
env:
NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}
run: yarn publish:ci
# Step 11: Post breaking changes to a Slack channel
- name: Post breaking changes to a Slack channel
env:
SLACK_WEBHOOK_URL: ${{ secrets.SDS_BREAKING_CHANGES_SLACK_WEBHOOK }}
uses: act10ns/slack@v1
with:
status: complete
channel: "#sci-design-system-breaking-changes"
config: .github/config/slack.yml
if: contains(toJson(github.event.commits.*.message), 'BREAKING CHANGE')
# Job 2
create-version-matrix:
needs: release
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}
steps:
# Step 1: Check out the repository code
- name: Checkout Repository
uses: actions/checkout@v3
with:
fetch-depth: 0
ref: prod
# Step 2: Create a matrix of package versions and names
- name: Create Versions Matrix
id: set-matrix
run: |
matrix="["
for package_json in $(find ./packages -name package.json); do
version=$(jq -r .version "$package_json")
name=$(jq -r .name "$package_json")
matrix="${matrix}{\"name\":\"${name}\", \"version\":\"${version}\"},"
done
matrix="${matrix%,}" # Remove trailing comma
matrix="${matrix}]" # Close the JSON array
echo "matrix=${matrix}" >> $GITHUB_OUTPUT
# Job 3
create-github-release:
needs: create-version-matrix
runs-on: ubuntu-latest
strategy:
matrix:
cfg: ${{fromJson(needs.create-version-matrix.outputs.matrix)}}
steps:
# Step 1: Create a GitHub release for the latest version
- name: Release
uses: softprops/action-gh-release@v1
with:
tag_name: "${{ matrix.cfg.name }}@${{ matrix.cfg.version }}"