-
Notifications
You must be signed in to change notification settings - Fork 3
139 lines (131 loc) · 5.77 KB
/
publish-prerelease.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
133
134
135
136
137
138
139
name: Publish Pre-Release to NPM
on:
# When standard Pull Request is merged
pull_request:
branches:
- master
types: [ closed ]
jobs:
createReleasePullRequest:
if: "!contains(join(github.event.pull_request.labels.*.name, ','), 'Release') && github.event.pull_request.merged == true"
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
with:
fetch-depth: "0"
- name: Read .nvmrc
run: echo "NODE_VERSION=$(cat .nvmrc)" >> $GITHUB_OUTPUT
id: nvm
- name: Use Node.js ${{ steps.nvm.outputs.NODE_VERSION }}
uses: actions/setup-node@v2
with:
node-version: ${{ steps.nvm.outputs.NODE_VERSION }}
- name: Install Dependencies and Build Packages
run: |
yarn install
yarn build
- name: Git Identity
run: |
git config --global user.name 'frontegg'
git config --global user.email '[email protected]'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Authenticate with Registry
run: |
yarn logout
echo "init-author-name=Frontegg LTD" > .npmrc
echo "[email protected]" >> .npmrc
echo "init-author-url=https://frontegg.com" >> .npmrc
echo "init-license=MIT" >> .npmrc
echo "always-auth=true" >> .npmrc
echo "registry=https://registry.npmjs.org" >> .npmrc
echo "_authToken=$NPM_TOKEN" >> .npmrc
echo "@frontegg:registry=https://registry.npmjs.org" >> .npmrc
echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" >> .npmrc
npm whoami
env:
NPM_TOKEN: ${{ secrets.NPM_PUBLISH_TOKEN }}
- name: Commit Version UP
run: |
yarn lerna version patch --no-git-tag-version --yes --no-push --force-publish
yarn update-version
yarn prettier
- name: "Set Generated changelog"
uses: actions/github-script@v6
id: 'generated-changelog'
with:
result-encoding: string
script: |
const { generateChangeLog } = await import(`${process.env.GITHUB_WORKSPACE}/.github/scripts/index.js`);
return generateChangeLog({context, github, core})
- name: "Set incremented version"
uses: actions/github-script@v6
id: 'incremented-version'
with:
result-encoding: string
script: |
const {default: fs} = await import('fs');
const {version} = JSON.parse(fs.readFileSync('./lerna.json', {encoding: "utf-8"}));
return version;
- name: Commit changes
shell: bash -ex {0}
id: 'cpr_commit_sha'
run: |
git add . && git commit -m "chore(release): publish ${{ steps.incremented-version.outputs.result }}"
echo "sha=$(git rev-parse HEAD)" >> $GITHUB_OUTPUT
- name: Create Release Pull Request
id: cpr
uses: peter-evans/[email protected]
with:
token: ${{ secrets.GITHUB_TOKEN }}
path: ${{ secrets.GITHUB_WORKSPACE }}
commit-message: "Update v${{ steps.incremented-version.outputs.result }}"
committer: GitHub <[email protected]>
author: "${{ github.actor }} <${{ github.actor }}@users.noreply.github.com>"
title: 'v${{ steps.incremented-version.outputs.result }}'
body: |
# v${{ steps.incremented-version.outputs.result }}
${{steps.generated-changelog.outputs.result}}
labels: "Type: Release"
branch: "release/next"
- name: Publish Pre-Release version to NPM
id: publish_pre_release_version
run: |
version=$(node -p 'require("./lerna.json").version')
echo "LIB_VERSION=${version}" >> $GITHUB_OUTPUT
echo "Publishing DEV version - v${version}-alpha.${{ github.run_id }}"
alphaVersion="${version}-alpha.${{ github.run_id }}"
yarn lerna version --no-git-tag-version --yes --no-push --exact "${alphaVersion}"
yarn update-version
yarn build
cp "./.npmrc" "./dist/@frontegg/nextjs/.npmrc"
cp "./.npmignore" "./dist/@frontegg/nextjs/.npmignore"
cd "./dist/@frontegg/nextjs" && npm publish --tag next
env:
NPM_TOKEN: ${{ secrets.NPM_PUBLISH_TOKEN }}
- name: Notify Slack on alpha version deployment
uses: rtCamp/action-slack-notify@v2
env:
SLACK_CHANNEL: frontegg-alpha-versions
SLACK_COLOR: ${{ job.status }}
SLACK_ICON: https://avatars.githubusercontent.com/u/67857107?s=40&v=4
SLACK_MESSAGE: '${{ steps.publish_pre_release_version.outputs.LIB_VERSION }}-alpha.${{ github.run_id }} has been released :rocket:'
SLACK_TITLE: 'A new @frontegg/nextjs alpha version!'
SLACK_USERNAME: ${{ github.actor }}
SLACK_WEBHOOK: ${{ secrets.ROTEM_SLACK_WEBHOOK }}
MSG_MINIMAL: true
- name: Wait until NPM registry finished indexing the new version
uses: actions/github-script@v6
with:
script: |
const checkingVersion = '${{ steps.publish_pre_release_version.outputs.LIB_VERSION }}-alpha.${{ github.run_id }}';
const checkNpmVersions = require('./scripts/wait-for-npm-indexing.js');
await checkNpmVersions(github, ['@frontegg/nextjs'], checkingVersion);
- name: "Call trigger-e2e-test action"
uses: ./.github/actions/trigger-e2e-test
with:
version: ${{ steps.publish_pre_release_version.outputs.LIB_VERSION }}-alpha.${{ github.run_id }}
sha: ${{ steps.cpr_commit_sha.outputs.sha }}
bot_app_id: ${{ secrets.GH_FRONTEGG_BOT_APP_ID }}
bot_app_key: ${{ secrets.GH_FRONTEGG_BOT_APP_SECRET }}