-
Notifications
You must be signed in to change notification settings - Fork 9
141 lines (120 loc) · 3.92 KB
/
build-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
name: Build and Release
on:
workflow_dispatch:
inputs:
build_name:
description: "Build name"
default: ""
required: false
type: string
test_build:
description: "Test build"
default: false
required: false
type: boolean
run-name: ${{ inputs.build_name }}
defaults:
run:
shell: bash
jobs:
# Create linux release file
linux:
runs-on: ubuntu-latest
outputs:
app_ver: ${{ steps.get_ver.outputs.app_ver }}
sha256: ${{ steps.get_hash.outputs.hash_output }}
steps:
- name: Checkout master and submodules
uses: actions/checkout@v4
with:
submodules: "true"
- name: Fetch version number
id: get_ver
run: |
tp_ver=$(grep "^VERSION" "./tinypedal/const.py" | sed 's/[A-Z\ \=\"]//g')
echo "app_ver=${tp_ver}" >> $GITHUB_OUTPUT
echo "TinyPedal Version:" $tp_ver
- name: ZIP Linux file
run: |
file_name=TinyPedal-${{ steps.get_ver.outputs.app_ver }}-linux.zip
zip -r $file_name . -x *.git*
- name: Check hash sum
id: get_hash
run: |
sha256hash=$(sha256sum TinyPedal-${{ steps.get_ver.outputs.app_ver }}-linux.zip)
echo "hash_output=${sha256hash}" >> $GITHUB_OUTPUT
echo $sha256hash
- name: Upload release files
uses: softprops/action-gh-release@v2
if: ${{ !inputs.test_build }}
with:
token: ${{ secrets.GITHUB_TOKEN }}
tag_name: v${{ steps.get_ver.outputs.app_ver }}
files: |
TinyPedal-${{ steps.get_ver.outputs.app_ver }}-linux.zip
# Create windows release file
windows:
runs-on: windows-latest
needs: linux
outputs:
sha256: ${{ steps.get_hash.outputs.hash_output }}
steps:
- name: Checkout master and submodules
uses: actions/checkout@v4
with:
submodules: "true"
- name: Set up Python 3.8 environment for Windows build
uses: actions/setup-python@v5
with:
python-version: "3.8"
architecture: "x64"
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
pip install py2exe
- name: Build Windows executable
run: |
python freeze_py2exe.py -c
- name: ZIP Windows file
shell: pwsh
run: |
$file_name="TinyPedal-${{ needs.linux.outputs.app_ver }}-windows.zip"
Compress-Archive -Path ./dist/TinyPedal -DestinationPath ./$file_name
- name: Check hash sum
id: get_hash
run: |
sha256hash=$(sha256sum TinyPedal-${{ needs.linux.outputs.app_ver }}-windows.zip | sed 's/\*//g')
echo "hash_output=${sha256hash}" >> $GITHUB_OUTPUT
echo $sha256hash
- name: Upload release files
uses: softprops/action-gh-release@v2
if: ${{ !inputs.test_build }}
with:
token: ${{ secrets.GITHUB_TOKEN }}
tag_name: v${{ needs.linux.outputs.app_ver }}
files: |
TinyPedal-${{ needs.linux.outputs.app_ver }}-windows.zip
# Generate release notes
release-notes:
runs-on: ubuntu-latest
needs: [linux, windows]
steps:
- name: Checkout master and submodules
uses: actions/checkout@v4
- name: Get latest change log
run: |
prev_line_num=$(grep -n "^\----*$" "./docs/changelog.txt" | sed -n "2,2p" | sed 's/[\:\-]//g')
sed -n "1,$(expr $prev_line_num - 2)p" "./docs/changelog.txt" >> release.txt
echo "Hash sum" >> release.txt
echo "---" >> release.txt
echo "SHA256:" ${{ needs.linux.outputs.sha256 }} >> release.txt
echo "SHA256:" ${{ needs.windows.outputs.sha256 }} >> release.txt
cat release.txt
- name: Update release notes
uses: softprops/action-gh-release@v2
if: ${{ !inputs.test_build }}
with:
body_path: release.txt
token: ${{ secrets.GITHUB_TOKEN }}
tag_name: v${{ needs.linux.outputs.app_ver }}