-
Notifications
You must be signed in to change notification settings - Fork 32
146 lines (138 loc) · 5.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
133
134
135
136
137
138
139
140
141
142
143
144
145
146
name: Release & Publish to NPM
on:
workflow_dispatch:
inputs:
increment:
type: choice
description: Select increment
options:
- patch
- minor
- major
- beta
beta_version:
type: string
description: Type version if beta increment is selected
package:
type: choice
description: Select package
options:
- '@inworld/web-core'
- '@inworld/web-threejs'
env:
AUTH_SERVICE_ACCOUNT: [email protected]
AUTH_IDENTITY_PROVIDER: projects/678423885598/locations/global/workloadIdentityPools/github-devops-pool/providers/github-prvdr
jobs:
github-release:
runs-on: ubuntu-latest
steps:
- name: Set version
run: echo "VERSION=${{ inputs.increment}}" >> $GITHUB_ENV
- name: Set beta version
run: echo "VERSION=${{ inputs.beta_version }}" >> $GITHUB_ENV
if: inputs.beta_version != ''
- name: Echo version & package
run: echo "${{ env.VERSION }}" "${{ inputs.package }}"
- name: Set ref
run: echo "REF=main" >> $GITHUB_ENV
if: inputs.beta_version == ''
- name: Set config
run: echo "CONFIG=-c .release-it.prerelease.json" >> $GITHUB_ENV
if: inputs.beta_version != ''
- name: Set git user
run: git config --global user.email "[email protected]" && git config --global user.name "CI-inworld"
- name: Checkout source code
uses: actions/checkout@v3
with:
ref: ${{ env.REF }}
ssh-key: ${{ secrets.GH_SERVICE_ACCOUNT_SSH_KEY }}
- name: Run build
uses: ./.github/actions/build_package
- name: Bump version
run: |
npx yarn workspace ${{ inputs.package }} release:bump ${{ env.VERSION }} ${{ env.CONFIG }} --ci
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
npm-release:
runs-on: ubuntu-latest
needs: [github-release]
steps:
- name: Checkout source code
uses: actions/checkout@v3
with:
ref: ${{ env.REF }}
- name: Pull latest changes
run: git pull
- name: Run build
uses: ./.github/actions/build_package
with:
mode: 'prod'
- name: Set Tag
run: echo "TAG=--tag=beta" >> $GITHUB_ENV
if: inputs.beta_version != ''
- run: echo "npmAuthToken:" "${{ secrets.NPM_TOKEN }}" >> .yarnrc.yml
- name: Publish to npm
run: npx yarn workspace ${{ inputs.package }} release:publish ${{ env.TAG }}
minify-and-upload:
runs-on: [self-hosted, linux, x64, kubernetes, ephemeral]
needs: [npm-release]
if: inputs.beta_version == ''
permissions:
contents: 'read'
id-token: 'write'
steps:
- name: Checkout source code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set TAG as the latest one
run: echo "TAG=refs/tags/`echo $(git describe --tags --match="${{ inputs.package }}*" --abbrev=0)`" >> $GITHUB_ENV
- name: Minify and upload
uses: ./.github/actions/upload_minified_version
with:
package: ${{ inputs.package }}
tag: ${{ env.TAG }}
env:
AUTH_SERVICE_ACCOUNT: ${{ env.AUTH_SERVICE_ACCOUNT }}
AUTH_IDENTITY_PROVIDER: ${{ env.AUTH_IDENTITY_PROVIDER }}
release-notification:
runs-on: [self-hosted, kubernetes, nodocker]
needs: [github-release, npm-release]
# always runs even if previous tasks are not successful
if: always()
steps:
- name: Checkout source code
if: needs.npm-release.result == 'success'
uses: actions/checkout@v3
with:
ref: main
- name: Build version path
if: needs.npm-release.result == 'success'
run: |
echo "path=require('./packages${{ inputs.package }}/package.json').version" | sed 's/@inworld//g' >> $GITHUB_OUTPUT
id: extract-version-path
- name: Extract version
if: needs.npm-release.result == 'success'
run: |
echo "version=$(node -e "console.log(${{ steps.extract-version-path.outputs.path }})")" >> $GITHUB_OUTPUT
id: extract-version
- name: Extract changelog
if: needs.npm-release.result == 'success'
run: |
echo "changelog=./packages${{ inputs.package }}/CHANGELOG.md" | sed 's/@inworld//g' >> $GITHUB_OUTPUT
id: extract-changelog
- name: Extract release notes
if: needs.npm-release.result == 'success'
id: extract-release-notes
uses: ffurrer2/extract-release-notes@v1
with:
changelog_file: ${{ steps.extract-changelog.outputs.changelog }}
- name: Slack Notification
if: always()
uses: rtCamp/action-slack-notify@v2
env:
SLACK_WEBHOOK: ${{ secrets.INTEGRATIONS_SLACK_WEBHOOK }}
SLACK_COLOR: ${{ contains(needs.*.result, 'failure') && 'danger' || 'good' }}
SLACK_TITLE: Release ${{ contains(needs.*.result, 'failure') && 'failure' || steps.extract-version.outputs.version }}
SLACK_MESSAGE: ${{ contains(needs.*.result, 'failure') && ':x:' || steps.extract-release-notes.outputs.release_notes }}
SLACK_FOOTER: '-Web SDK-'