-
Notifications
You must be signed in to change notification settings - Fork 24
117 lines (117 loc) · 6.21 KB
/
release-github.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
name: Release to GitHub and NPM
on:
workflow_dispatch:
push:
branches:
- 'main'
- 'next'
- 'next-major'
- 'proposed'
pull_request:
types: [opened, synchronize]
branches:
- 'next'
- 'proposed'
- 'pr-channel'
env:
HUSKY: 0
jobs:
release:
name: Release
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
with:
fetch-depth: 0
repo-token: ${{ secrets.SEMANTIC_RELEASE_BOT_PAT }}
persist-credentials: false
- name: Setup Node.js
uses: actions/setup-node@v2
with:
node-version: 'lts/*'
- name: Set up NPM token
env:
NPM_TOKEN: ${{ secrets.SEMANTIC_RELEASE_NPM_TOKEN }} # <-- allow npm publish for each workspace
run: 'echo "//registry.npmjs.org/:_authToken=${NPM_TOKEN}" > .npmrc'
- name: Install dependencies
run: npm ci
- name: Set explicit npm dist-tag default
if: github.ref_name == 'main'
run: |
echo "NPM_DIST_TAG=latest" >> $GITHUB_ENV
echo "RELEASE_CHANNEL=latest" >> $GITHUB_ENV
- name: Override npm dist-tag for non-main releases
if: github.ref_name != 'main'
run: |
echo "Setting NPM_DIST_TAG to '${{ github.ref_name }}'"
echo "NPM_DIST_TAG=${{ github.ref_name }}" >> $GITHUB_ENV
- name: Override release channel for non-main releases
if: github.ref_name != 'main'
run: |
echo "Setting RELEASE_CHANNEL to '$(node ./src/js/version.mjs channel $NPM_DIST_TAG)' using branch name '$NPM_DIST_TAG'"
echo "RELEASE_CHANNEL=$(node ./src/js/version.mjs channel $NPM_DIST_TAG)" >> $GITHUB_ENV
- name: Override release channel for PRs
if: github.event_name == 'pull_request'
run: |
echo "Setting RELEASE_CHANNEL to 'pr${{ github.event.number }}'"
echo "RELEASE_CHANNEL=pr${{ github.event.number }}" >> $GITHUB_ENV
- name: Release mono-artifact to GitHub
if: (github.ref_name != 'main' && github.event_name != 'pull_request') || github.event_name == 'workflow_dispatch'
env:
GITHUB_TOKEN: ${{ secrets.SEMANTIC_RELEASE_BOT_PAT }} # <-- Allows semantic-release-bot to push changes to protected branches
npm_config_tag: ${{ env.NPM_DIST_TAG }} # <-- For main, this is `latest.` Otherwise, `next`, `next-major`, etc. See ./.releaserc for release branch config.
run: npx semantic-release
- name: Dry-run mono-artifact
if: (github.ref_name == 'main' && github.event_name != 'workflow_dispatch') || github.event_name == 'pull_request'
env:
GITHUB_TOKEN: ${{ secrets.SEMANTIC_RELEASE_BOT_PAT }} # <-- Allows semantic-release-bot to push changes to protected branches
npm_config_tag: ${{ env.NPM_DIST_TAG }} # <-- For main, this is `latest.` Otherwise, `next`, `next-major`, etc. See ./.releaserc for release branch config.
run: npx semantic-release --dry-run
- name: Build artifacts for PRs
if: github.event_name == 'pull_request'
run: npm run dist
- name: Check if semantic-release created a build
id: check_build
uses: andstor/file-existence-action@v2
with:
files: "./src/sdks/core/dist/lib/firebolt.mjs"
- name: Release Firebolt SDKs to NPM
#if: steps.check_build.outputs.files_exists == 'true' && github.event_name != 'pull_request' && (github.ref_name != 'main' || github.event_name == 'workflow_dispatch')
if: steps.check_build.outputs.files_exists == 'true' && (github.ref_name != 'main' || github.event_name == 'workflow_dispatch')
env:
NPM_TOKEN: ${{ secrets.SEMANTIC_RELEASE_NPM_TOKEN }} # <-- Allows semantic-release to publish to npm without 2 factor auth.
npm_config_tag: ${{ env.NPM_DIST_TAG }} # <-- For main, this is `latest.` Otherwise, `next`, `next-major`, etc. See ./.releaserc for release branch config.
run: |
echo "NPM DIST TAG ::: " ${{ env.NPM_DIST_TAG }}
echo "Release Channel ::: " $RELEASE_CHANNEL
npm publish --tag $RELEASE_CHANNEL --workspaces
- name: Dry-run Firebolt SDKs to NPM
if: steps.check_build.outputs.files_exists == 'true' && (github.ref_name == 'main' && github.event_name != 'workflow_dispatch')
env:
NPM_TOKEN: ${{ secrets.SEMANTIC_RELEASE_NPM_TOKEN }} # <-- Allows semantic-release to publish to npm without 2 factor auth.
npm_config_tag: ${{ env.NPM_DIST_TAG }} # <-- For main, this is `latest.` Otherwise, `next`, `next-major`, etc. See ./.releaserc for release branch config.
run: npm publish --tag $RELEASE_CHANNEL --workspaces --dry-run
- name: Checkout firebolt GitHub.io repository
if: steps.check_build.outputs.files_exists == 'true'
env:
GITHUB_TOKEN: ${{ secrets.SEMANTIC_RELEASE_BOT_PAT }} # <-- Allows semantic-release-bot to push changes to protected branches
npm_config_tag: ${{ env.NPM_DIST_TAG }} # <-- For main, this is `latest.` Otherwise, `next`, `next-major`, etc. See ./.releaserc for release branch config.
run: |
cd /tmp
git clone https://rdkcentral:[email protected]/rdkcentral/firebolt.git ./firebolt-docs
- name: Release docs to GitHub.io
if: (steps.check_build.outputs.files_exists == 'true' && github.event.pull_request.head.repo.full_name == 'rdkcentral/firebolt-apis')
env:
GITHUB_TOKEN: ${{ secrets.SEMANTIC_RELEASE_BOT_PAT }} # <-- Allows semantic-release-bot to push changes to protected branches
npm_config_tag: ${{ env.NPM_DIST_TAG }} # <-- For main, this is `latest.` Otherwise, `next`, `next-major`, etc. See ./.releaserc for release branch config.
run: |
echo "GitHub Config :::: '${{ github.event.pull_request.head.repo.full_name }}'"
echo "GitHub Event Name :::: '${{ github.event_name }}'"
npm run publish:docs /tmp/firebolt-docs $RELEASE_CHANNEL
cd /tmp/firebolt-docs
git config --global user.email "[email protected]"
git config --global user.name "Your Name"
git add --all
git diff-index --quiet HEAD || git commit -m "chore: Publish $RELEASE_CHANNEL"
git push