-
Notifications
You must be signed in to change notification settings - Fork 41
159 lines (140 loc) · 6.75 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
147
148
149
150
151
152
153
154
155
156
157
158
159
name: Release
on:
push:
branches:
- release/*
- hotfix/*
- preview/*
tags: ["*"]
permissions:
id-token: write
contents: read
concurrency:
group: release
jobs:
release:
strategy:
fail-fast: false
matrix:
include:
- packCmd: l
os: ubuntu-latest
- packCmd: m
os: macos-latest
- packCmd: w
os: macos-latest
runs-on: ${{ matrix.os }}
environment:
name: ${{ startsWith(github.event.ref, 'refs/tags/') && 'main' || startsWith(github.event.ref, 'refs/heads/preview/') && 'preview' || 'internal' }}
steps:
- uses: actions/[email protected]
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v3
with:
role-to-assume: arn:aws:iam::${{ secrets.AWS_ACCOUNT_ID }}:role/${{ secrets.AWS_ROLE_TO_ASSUME }}
role-session-name: GitHubActions-${{ github.run_id }}
role-duration-seconds: 3000
aws-region: ap-northeast-2
- name: Set up Java
uses: actions/[email protected]
with:
distribution: "temurin"
java-version: "11"
- name: Sync time on Ubuntu
continue-on-error: true
if: runner.os == 'Linux'
run: sudo chronyc -a makestep
- name: Sync time on macOS
continue-on-error: true
if: runner.os == 'macOS'
run: |
UNIX_TIMESTAMP=$(curl -s http://worldtimeapi.org/api/ip | jq '.unixtime')
echo "Unix timestamp is: $UNIX_TIMESTAMP"
sudo systemsetup -setusingnetworktime off
sudo date -r $UNIX_TIMESTAMP
sudo systemsetup -setusingnetworktime on
- name: Copy builder config
shell: bash
run: |
sh scripts/download-codesigner.sh
if [[ "${{ startsWith(github.event.ref, 'refs/tags/') }}" == true ]]
then
sed "s/Please replace it/${{ secrets.APPLE_TEAM_ID }}/g" electron-builder.main.yml > temp2.txt
mv temp2.txt electron-builder.main.yml
elif [[ "${{ startsWith(github.event.ref, 'refs/heads/preview/') }}" == true ]]
then
timestamp=$(date +%y%m%d%H%M%S)
version=$(jq -r .version package.json | awk -F'.' '{print $1"."$2}')
jq --arg version "$version.$timestamp" '.version = $version' package.json > tmp.$$.json && mv tmp.$$.json package.json
jq --arg suffix " Preview" '.productName += $suffix' package.json > tmp.$$.json && mv tmp.$$.json package.json
jq --arg suffix "Preview" '.name += $suffix' package.json > tmp.$$.json && mv tmp.$$.json package.json
sed 's/NineChronicles@workspace/NineChroniclesPreview@workspace/g' yarn.lock > temp1.txt
mv temp1.txt yarn.lock
mv ./signing/sandbox_code_sign_tool.properties ./tmp/codesign/conf/code_sign_tool.properties
sed "s/Please replace it/${{ secrets.APPLE_TEAM_ID }}/g" electron-builder.preview.yml > temp2.txt
mv temp2.txt electron-builder.preview.yml
else
timestamp=$(date +%y%m%d%H%M%S)
version=$(jq -r .version package.json | awk -F'.' '{print $1"."$2}')
jq --arg version "$version.$timestamp" '.version = $version' package.json > tmp.$$.json && mv tmp.$$.json package.json
jq --arg suffix " Internal" '.productName += $suffix' package.json > tmp.$$.json && mv tmp.$$.json package.json
jq --arg suffix "Internal" '.name += $suffix' package.json > tmp.$$.json && mv tmp.$$.json package.json
sed 's/NineChronicles@workspace/NineChroniclesInternal@workspace/g' yarn.lock > temp1.txt
mv temp1.txt yarn.lock
mv ./signing/sandbox_code_sign_tool.properties ./tmp/codesign/conf/code_sign_tool.properties
sed "s/Please replace it/${{ secrets.APPLE_TEAM_ID }}/g" electron-builder.internal.yml > temp2.txt
mv temp2.txt electron-builder.internal.yml
fi
- name: Cache electron-gyp
uses: actions/[email protected]
with:
path: ~/.electron-gyp
key: ${{ runner.os }}-electron-gyp
- uses: actions/[email protected]
with:
node-version: 20
cache: "yarn"
- name: Install
shell: bash
run: yarn
- name: Set environment variables for Mac
if: matrix.packCmd == 'm'
run: |
echo "CSC_LINK=${{ secrets.CSC_LINK }}" >> $GITHUB_ENV
echo "CSC_KEY_PASSWORD=${{ secrets.CSC_KEY_PASSWORD }}" >> $GITHUB_ENV
- name: release
shell: bash
run: |
if [[ "${{ startsWith(github.event.ref, 'refs/tags/') }}" == true ]]
then
sh ./scripts/release.sh main ${{ matrix.packCmd }}
aws cloudfront create-invalidation --distribution-id ${{ secrets.CF_DISTRIBUTION_ID }} --paths "/main/launcher/latest.yml"
aws cloudfront create-invalidation --distribution-id ${{ secrets.CF_DISTRIBUTION_ID }} --paths "/main/launcher/latest-mac.yml"
elif [[ "${{ startsWith(github.event.ref, 'refs/heads/preview/') }}" == true ]]
then
sh ./scripts/release.sh preview ${{ matrix.packCmd }}
aws cloudfront create-invalidation --distribution-id ${{ secrets.CF_DISTRIBUTION_ID }} --paths "/main/launcher/latest.yml"
aws cloudfront create-invalidation --distribution-id ${{ secrets.CF_DISTRIBUTION_ID }} --paths "/main/launcher/latest-mac.yml"
else
sh ./scripts/release.sh internal ${{ matrix.packCmd }}
aws cloudfront create-invalidation --distribution-id ${{ secrets.CF_DISTRIBUTION_ID }} --paths "/internal/launcher/latest.yml"
aws cloudfront create-invalidation --distribution-id ${{ secrets.CF_DISTRIBUTION_ID }} --paths "/internal/launcher/latest-mac.yml"
fi
bash ./scripts/purge-ncloud-cdn.sh ${{ secrets.NAVER_CLOUD_ACCESS_KEY }} ${{ secrets.NAVER_CLOUD_SECRET_KEY }} ${{ secrets.NAVER_CLOUD_CDN_ID }}
curl -X POST -H 'Content-type: application/json' --data '{"text":"[Launcher] Had success releasing with '${{ matrix.packCmd }}' pack-cmd"}' ${{ secrets.SLACK_WEBHOOK }}
rm -fR ./dist/*-unpacked
rm -fR ./dist/mac
rm -fR ./dist/mac-arm64
env:
APPLE_ID: ${{ secrets.APPLE_ID }}
APPLE_APP_SPECIFIC_PASSWORD: ${{ secrets.APPLE_APP_SPECIFIC_PASSWORD }}
ESIGNER_CREDENTIAL_ID: ${{ secrets.ESIGNER_CREDENTIAL_ID }}
ESIGNER_USERNAME: ${{ secrets.ESIGNER_USERNAME }}
ESIGNER_PASSWORD: ${{ secrets.ESIGNER_PASSWORD }}
ESIGNER_TOTP_SECRET: ${{ secrets.ESIGNER_TOTP_SECRET }}
- uses: actions/[email protected]
with:
path: dist
name: Dist-${{ matrix.packCmd }}
retention-days: 3
if-no-files-found: error