-
Notifications
You must be signed in to change notification settings - Fork 115
95 lines (82 loc) · 2.73 KB
/
cd.yml
File metadata and controls
95 lines (82 loc) · 2.73 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
name: Build, Deploy & Create GitHub Release
on:
push:
branches:
- main
paths-ignore:
- '**.md'
workflow_dispatch:
permissions:
contents: write
jobs:
check_release:
runs-on: ubuntu-latest
outputs:
should_run: ${{ steps.check.outputs.should_run }}
steps:
- name: Check if release merge or workflow dispatch
id: check
uses: actions/github-script@v8
with:
script: |
const shouldRun = context.eventName === 'workflow_dispatch' ||
/Release \d{6}/.test(context.payload.head_commit.message);
core.setOutput('should_run', shouldRun);
build_deploy:
name: Build & Deploy
runs-on: ubuntu-latest
needs: check_release
if: needs.check_release.outputs.should_run == 'true'
outputs:
version: ${{ steps.get_version.outputs.version }}
steps:
- name: Checkout
uses: actions/checkout@v5
with:
fetch-depth: 0
token: ${{ secrets.GITHUB_TOKEN }}
- name: Setup Bun
uses: oven-sh/setup-bun@v2
with:
bun-version: latest
- name: Install
run: bun install --frozen-lockfile
- name: Build for Staging
run: bun run build:staging
- name: Build for Production
run: bun run build:prod
- name: Authenticate to Google Cloud
uses: google-github-actions/auth@v1
with:
credentials_json: '${{ secrets.GOOGLE_CREDENTIALS }}'
- name: Upload SDK Files to GCS
uses: google-github-actions/upload-cloud-storage@v1
with:
path: 'build/releases'
destination: 'sdk-builds-persistence-onesignal/web-sdk/${{ github.sha }}'
parent: false
- name: Get version
id: get_version
run: |
SDK_VERSION=$(bun -e "console.log(require('./package.json').config.sdkVersion)")
if git rev-parse "$SDK_VERSION" >/dev/null 2>&1; then
echo "Tag $SDK_VERSION already exists, skipping release"
else
echo "version=$SDK_VERSION" >> $GITHUB_OUTPUT
fi
- name: Create turbine PR
if: steps.get_version.outputs.version != ''
run: ./build/scripts/turbine.sh
env:
GH_TURBINE_TOKEN: ${{ secrets.GH_TURBINE_TOKEN }}
GITHUB_SHA: ${{ github.sha }}
GITHUB_RUN_ID: ${{ github.run_id }}
SDK_VERSION: ${{ steps.get_version.outputs.version }}
create_github_release:
needs: build_deploy
if: needs.build_deploy.outputs.version != ''
uses: OneSignal/sdk-shared/.github/workflows/github-release.yml@main
secrets:
GH_PUSH_TOKEN: ${{ secrets.GH_PUSH_TOKEN }}
with:
version: ${{ needs.build_deploy.outputs.version }}