-
Notifications
You must be signed in to change notification settings - Fork 0
135 lines (113 loc) · 3.31 KB
/
release.yml
File metadata and controls
135 lines (113 loc) · 3.31 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
name: Release
on:
push:
tags:
- v*
jobs:
test-and-build:
runs-on: ubuntu-24.04
steps:
- name: Clone
uses: actions/checkout@v3
- uses: actions/setup-node@v4
with:
cache: "npm"
node-version-file: '.nvmrc'
- name: Install
run: npm ci
- name: Build
run: npm run build
- name: Unit Test
run: npm run test
- name: Upload dist
uses: actions/upload-artifact@v4
with:
name: dist
path: |
dist/*
publish-github-release:
name: Publish to GitHub
runs-on: ubuntu-24.04
needs: test-and-build
steps:
- name: Get Token
id: get_workflow_token
uses: peter-murray/workflow-application-token-action@v2
with:
application_id: ${{ secrets.CC_OSS_BOT_ID }}
application_private_key: ${{ secrets.CC_OSS_BOT_PEM }}
- name: Swap to main
uses: actions/checkout@v3
with:
ref: main
fetch-depth: 0 # Full fetch
token: ${{ steps.get_workflow_token.outputs.token }}
- name: Get Version
run: |
GIT_VERSION=$(node ./.backstage/get_tagged_version.cjs)
echo GIT_VERSION="$GIT_VERSION" >> $GITHUB_ENV
- name: Get Release Tag
run: |
NPM_TAG=$(node ./.backstage/get_npm_tag.cjs)
echo NPM_TAG="$NPM_TAG" >> $GITHUB_ENV
- name: Download dist
uses: actions/download-artifact@v4
with:
name: dist
path: dist
- name: List files
run: ls -R dist
- name: Stable Release
uses: softprops/action-gh-release@v2.2.2
if: startsWith(github.ref, 'refs/tags/') && env.NPM_TAG == 'latest'
with:
files: |
dist/*
env:
GITHUB_TOKEN: ${{ steps.get_workflow_token.outputs.token }}
- name: Prerelease
uses: softprops/action-gh-release@v2.2.2
if: startsWith(github.ref, 'refs/tags/') && env.NPM_TAG != 'latest'
with:
prerelease: true
files: |
dist/*
env:
GITHUB_TOKEN: ${{ steps.get_workflow_token.outputs.token }}
publish-npm-release:
runs-on: ubuntu-24.04
needs: publish-github-release
steps:
- name: Clone
uses: actions/checkout@v3
- uses: actions/setup-node@v4
with:
cache: "npm"
node-version-file: '.nvmrc'
- name: Get Version
run: |
GIT_VERSION=$(node ./.backstage/get_tagged_version.cjs)
echo GIT_VERSION="$GIT_VERSION" >> $GITHUB_ENV
- name: Get Release Tag
run: |
NPM_TAG=$(node ./.backstage/get_npm_tag.cjs)
echo NPM_TAG="$NPM_TAG" >> $GITHUB_ENV
- name: Prepare package
run: |
npm --no-git-tag-version version $GIT_VERSION
- name: Install
run: npm ci
- name: Build
run: npm run build
- name: Publish internal
uses: JS-DevTools/npm-publish@v3
with:
tag: ${{ env.NPM_TAG }}
token: ${{ secrets.GITHUB_TOKEN }}
registry: "https://npm.pkg.github.com"
- name: Publish external
uses: JS-DevTools/npm-publish@v3
with:
tag: ${{ env.NPM_TAG }}
token: ${{ secrets.NPM_TOKEN }}
access: public