-
Notifications
You must be signed in to change notification settings - Fork 0
141 lines (124 loc) · 4.27 KB
/
build-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
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 -> Create Release
# yamllint disable rule:line-length
on:
workflow_dispatch:
inputs:
version:
description: 'The version for the release'
required: true
default: '0.0.0'
draft:
description: 'Whether the release should be a draft '
required: true
default: 'true'
jobs:
validate:
name: Validates inputs
runs-on: ubuntu-latest
permissions:
contents: read
steps:
#validates that the version is a valid semver
- name: Validate version
id: validate_version
run: |
if [[ ! ${{ inputs.version }} =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
echo "Invalid version: ${{ inputs.version }}"
exit 1
fi
#validates that the draft is a valid boolean
- name: Validate draft
id: validate_draft
run: |
if [[ ! ${{ inputs.draft }} =~ ^(true|false)$ ]]; then
echo "Invalid draft: ${{ inputs.draft }}"
exit 1
fi
build:
name: Build packages
needs: validate
runs-on: ${{ matrix.os }}
strategy:
matrix:
include:
- os: macos-latest
TARGET: macos
CMD_BUILD: >
pyinstaller podshell.spec &&
pyinstaller podshell-console.spec &&
cd dist &&
zip -r9 podshell-macos *
OUT_FILE_NAME: podshell-macos.zip
- os: windows-latest
TARGET: windows
CMD_BUILD: >
pyinstaller podshell.spec &&
pyinstaller podshell-console.spec &&
cd dist &&
tar -acvf podshell-windows.zip podshell-console.exe podshell.exe
OUT_FILE_NAME: podshell-windows.zip
permissions:
contents: write
steps:
- name: Checkout
uses: actions/[email protected]
- name: Set up Python 3.11
uses: actions/[email protected]
with:
python-version: 3.11
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r ./requirements.txt
pip install pyinstaller
pip install Pillow
- name: Build with pyinstaller for ${{matrix.TARGET}}
run: ${{matrix.CMD_BUILD}}
- name: Archive artifacts
uses: actions/[email protected]
with:
name: ${{ matrix.OUT_FILE_NAME }}
path: dist/${{ matrix.OUT_FILE_NAME }}
if-no-files-found: error
create_release:
name: Create Release
runs-on: ubuntu-latest
needs: build
permissions:
contents: write
steps:
- name: Get current date and time
id: datetime
run: |
datetime=$(date +'%Y-%m-%dT%H-%M-%SZ')
echo "datetime=$datetime" >> $GITHUB_OUTPUT
- name: Display Run Name
run: echo ${{ steps.datetime.outputs.datetime }}
- name: Checkout
uses: actions/[email protected]
# note: this will download all artifacts to a directory for each artifact
# https://github.com/actions/download-artifact/tree/v2.1.1/#download-all-artifacts
- name: Download artifacts
uses: actions/[email protected]
with:
path: dist/
- name: Display structure of downloaded files
run: ls -R
working-directory: dist/
- name: Create release branch
run: |
git checkout -b "release/${{ inputs.version }}"
git push origin "release/${{ inputs.version }}"
- name: Create DRAFT release through github cli and upload assets
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
if: ${{ inputs.draft == 'true' }}
run: |
gh release create ${{ inputs.version }} --title ${{ inputs.version }} --generate-notes 'dist/podshell-macos.zip/podshell-macos.zip' 'dist/podshell-windows.zip/podshell-windows.zip' --draft
- name: Create PUBLISHED release through github cli and upload assets
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
if: ${{ inputs.draft == 'false' }}
run: |
gh release create ${{ inputs.version }} --title ${{ inputs.version }} --generate-notes 'dist/podshell-macos.zip/podshell-macos.zip' 'dist/podshell-windows.zip/podshell-windows.zip'