-
Notifications
You must be signed in to change notification settings - Fork 32
109 lines (107 loc) · 4 KB
/
create-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
name: Create GitHub Release
on: workflow_dispatch
jobs:
build:
strategy:
matrix:
os: [windows-latest, macos-latest]
name: Build (${{ matrix.os }})
runs-on: ${{ matrix.os }}
steps:
- name: Checkout ${{ github.repository }} @ ${{ github.ref }}
uses: actions/checkout@v4
with:
repository: ${{ github.repository }}
ref: ${{ github.ref }}
fetch-depth: 1
- name: Install NodeJS
uses: actions/setup-node@v4
with:
node-version: 22.x
- name: Install NPM Packages
run: npm install
- name: Build Application
run: npm run bundle --workspace app/nw --workspace app/electron
- name: Upload NW Builds
uses: actions/upload-artifact@v4
with:
name: bundle-nw-${{ matrix.os }}
retention-days: 3
path: app/nw/bundle/
- name: Upload Electron Builds
uses: actions/upload-artifact@v4
with:
name: bundle-electron-${{ matrix.os }}
retention-days: 3
path: app/electron/bundle/
release-notes:
needs: build
name: Prepare Release Notes
runs-on: ubuntu-latest
steps:
- name: Checkout ${{ github.repository }} @ ${{ github.ref }}
uses: actions/checkout@v4
with:
repository: ${{ github.repository }}
ref: ${{ github.ref }}
fetch-depth: 1
- name: Upload Release Templates
uses: actions/upload-artifact@v4
with:
name: release-templates
retention-days: 3
path: .github/RELEASE_TEMPLATE/*.md
publish:
needs:
- build
- release-notes
name: Publish Release
runs-on: ubuntu-latest
steps:
- name: Setup Environment
run: |
echo "RELEASE_DATE=$(date -u +"%Y-%m-%dT%H:%M:%SZ")" >> $GITHUB_ENV
echo "RELEASE_TAG=$(date -u +"%y%m%dT%H%M")" >> $GITHUB_ENV
- name: Download Artifacts
uses: actions/download-artifact@v4
- name: Create Release Description
run: |
DESCRIPTION=$(cat ./release-templates/pre-release.md | jq -sR | sed s/{TAG}/$RELEASE_TAG/g)
DESCRIPTION=$(echo $DESCRIPTION | sed s/{WIN_64_ZIP}/$(ls ./bundle-nw-* | grep 'x64.zip')/g)
DESCRIPTION=$(echo $DESCRIPTION | sed s/{WIN_32_ZIP}/$(ls ./bundle-nw-* | grep 'ia32.zip')/g)
DESCRIPTION=$(echo $DESCRIPTION | sed s/{MACOS_X64_DMG}/$(ls ./bundle-nw-* | grep 'x64.dmg')/g)
DESCRIPTION=$(echo $DESCRIPTION | sed s/{MACOS_ARM64_DMG}/$(ls ./bundle-nw-* | grep 'arm64.dmg')/g)
echo -n $DESCRIPTION > ./release-templates/description.md
- name: Create Release Tag
run: |
echo { > ./body.json
echo \"prerelease\":true, >> ./body.json
echo \"tag_name\":\"$RELEASE_TAG\", >> ./body.json
echo \"name\":\"canary • $RELEASE_DATE\", >> ./body.json
echo \"body\":$(cat ./release-templates/description.md) >> ./body.json
echo } >> ./body.json
echo +++ REQUEST +++
cat ./body.json
echo -n "RELEASE_ID=" >> $GITHUB_ENV
curl \
-X POST \
-H 'Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}' \
'https://api.github.com/repos/${{ github.repository }}/releases' \
--data @./body.json \
--silent > ./response.json
echo +++ RESPONSE +++
cat ./response.json
cat ./response.json | grep '"upload_url"' | cut -d'/' -f8 >> $GITHUB_ENV
rm body.json response.json
- name: Upload Release Assets
run: |
for FILE in ./bundle-*/*.*; do \
curl \
-X POST \
-H 'Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}' \
-H 'Content-Type: application/octet-stream' \
"https://uploads.github.com/repos/${{ github.repository }}/releases/${{ env.RELEASE_ID }}/assets?name=$(basename $FILE)" \
--data-binary @"$FILE" \
--silent \
&& echo \
; done