-
-
Notifications
You must be signed in to change notification settings - Fork 11
131 lines (129 loc) · 4.81 KB
/
build.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
---
name: Buld a release
on:
pull_request:
types: [closed]
branches:
- master
jobs:
create-release:
name: Create Release
runs-on: ubuntu-latest
outputs:
tag: ${{ steps.get-version.outputs.tag }}
release_url: ${{ steps.release-url.outputs.release_url }}
name: ${{ steps.get-name.outputs.name }}
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Get version
id: get-version
run: |
echo "tag=v$(cat version.txt)" >> $GITHUB_OUTPUT
- name: Get name
id: get-name
run: |
echo "name=$(basename ${GITHUB_REPOSITORY})" >> $GITHUB_OUTPUT
- name: Update changelog
id: update-changelog
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
API_URL="https://api.github.com/repos/${{ github.repository }}/pulls/${{ github.event.pull_request.number }}/commits"
COMMITS=$(curl -s -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" "$API_URL" | jq -r 'map(select(.commit.message | startswith("chore:") | not)) | .[] | "* \(.commit.message) [\(.sha[:7])](\(.html_url))"')
echo "# Changelog" > changelog.tmp
echo "" >> changelog.tmp
echo "## v$(cat version.txt)" >> changelog.tmp
echo "" >> changelog.tmp
echo "$COMMITS" >> changelog.tmp
echo "$COMMITS" > release_msg.tmp
tail -n +2 CHANGELOG.md >> changelog.tmp
mv changelog.tmp CHANGELOG.md
git config --local user.email "github-actions[bot]@users.noreply.github.com"
git config --local user.name "github-actions[bot]"
git add CHANGELOG.md
git commit -m "chore: update changelog"
git push
echo "release_text_path=$(realpath release_msg.tmp)" >> $GITHUB_OUTPUT
- name: Create Empty GH Release
id: create-release
uses: softprops/action-gh-release@v1
with:
tag_name: ${{ steps.get-version.outputs.tag }}
body_path: ${{ steps.update-changelog.outputs.release_text_path }}
- name: Output Release URL File
id: release-url
run: |
echo "release_url=${{ steps.create-release.outputs.upload_url }}" >> $GITHUB_OUTPUT
package-source:
name: Package Source
needs: create-release
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Compress Source
id: package-app
run: |
ci/pack-source.sh "${{needs.create-release.outputs.name}}-Source-all-${{needs.create-release.outputs.tag}}"
- name: Upload release asset for ${{matrix.target}}
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ needs.create-release.outputs.release_url}}
asset_path: ${{ steps.package-app.outputs.asset_path }}
asset_name: ${{ steps.package-app.outputs.asset_name }}
asset_content_type: application/zip
build:
name: Build Packages
needs: create-release
runs-on: ${{ matrix.os }}
strategy:
matrix:
include:
- os: macos-latest
TARGET: MacOS
ARCHITECTURE: x64
BUILD_CMD: ci/build.sh
PACKAGE_CMD: ci/package.sh
- os: windows-latest
TARGET: Windows
ARCHITECTURE: x64
BUILD_CMD: ci/build.ps1
PACKAGE_CMD: ci/package.ps1
- os: ubuntu-latest
ARCHITECTURE: x64
TARGET: Ubuntu
BUILD_CMD: ci/build.sh
PACKAGE_CMD: ci/package.sh
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Set up Python for ${{matrix.target}}
uses: actions/setup-python@v4
with:
python-version: '3.x'
- name: Set up Node
uses: actions/setup-node@v3
with:
node-version: 18
- name: Install dependencies for ${{matrix.target}}
run: |
pip install pyinstaller websockets bleak requests
pushd ui && npm install && popd
- name: Build application for ${{matrix.target}}
run: ${{ matrix.BUILD_CMD }}
- name: Package application for ${{matrix.TARGET}}
id: package-app
run: |
${{ matrix.PACKAGE_CMD }} "${{needs.create-release.outputs.name}}-${{matrix.TARGET}}-${{matrix.ARCHITECTURE}}-${{needs.create-release.outputs.tag}}"
- name: Upload release asset for ${{matrix.target}}
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ needs.create-release.outputs.release_url}}
asset_path: ${{ steps.package-app.outputs.asset_path }}
asset_name: ${{ steps.package-app.outputs.asset_name }}
asset_content_type: application/zip