-
Notifications
You must be signed in to change notification settings - Fork 0
142 lines (119 loc) · 3.82 KB
/
auto-make-prerelease.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
name: Auto Release on Version Change
on:
push:
branches:
- master
paths:
- 'pyproject.toml' # 当pyproject.toml文件变动时触发
jobs:
release:
runs-on: ubuntu-latest
outputs:
tag_exists: ${{ steps.check_tag_exists.outputs.exists }}
upload_url: ${{ steps.create_release.outputs.upload_url }}
version: ${{ steps.get_version.outputs.version }}
steps:
- name: Checkout Code
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v3
with:
python-version: '3.11'
- name: Install PDM
uses: pdm-project/setup-pdm@v3
- name: Get Project Version
id: get_version
run: |
echo "version=$(pdm show --version)" >> $GITHUB_OUTPUT
shell: bash
- name: Check if Git Tag exists
id: check_tag_exists
env:
VERSION: ${{ steps.get_version.outputs.version }}
run: |
git fetch --tags
if git rev-list -n 1 "v$VERSION" > /dev/null 2>&1; then
echo "Tag v$VERSION already exists."
echo "exists=1" >> $GITHUB_OUTPUT
else
echo "Tag v$VERSION does not exist."
echo "exists=0" >> $GITHUB_OUTPUT
fi
shell: bash
- name: Create Git Tag
if: steps.check_tag_exists.outputs.exists == 0
run: |
git tag v${{ steps.get_version.outputs.version }}
git push origin v${{ steps.get_version.outputs.version }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
shell: bash
- name: Install Dependencies
if: steps.check_tag_exists.outputs.exists == 0
run: |
pdm install -d
pdm list
shell: bash
- name: build
if: steps.check_tag_exists.outputs.exists == 0
run: |
eval $(pdm venv activate)
make
shell: bash
- name: rename binary
if: steps.check_tag_exists.outputs.exists == 0
run: |
mv dist/kazu dist/kazu-linux-${{ steps.get_version.outputs.version }}
- name: Render Default State-Transition Diagram
if: steps.check_tag_exists.outputs.exists == 0
run: |
eval $(pdm venv activate)
mkdir -p diagrams
kazu viz all -r -d diagrams
tar -zcvf diagrams.tar.gz diagrams
shell: bash
- name: Create GitHub Release
if: steps.check_tag_exists.outputs.exists == 0
id: create_release
uses: softprops/action-gh-release@v1
with:
tag_name: v${{ steps.get_version.outputs.version }}
files: |
./dist/*
./diagrams.tar.gz
draft: false
fail_on_unmatched_files: true
generate_release_notes: true
prerelease: false
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
build_win_binary:
needs: [release]
if: ${{ needs.release.outputs.tag_exists == 0 }}
runs-on: windows-latest
steps:
- name: Checkout Code
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v3
with:
python-version: '3.11'
- name: Install PDM
uses: pdm-project/setup-pdm@v3
- name: Install Dependencies
run: pdm install -d
- name: build
shell: pwsh
run: |
$env:PATH = ".venv\Scripts;" + $env:PATH
make build_bin
- name: Upload Release Asset
id: upload-release-asset
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ needs.release.outputs.upload_url }}
asset_path: ./dist/kazu.exe
asset_name: kazu-win-${{ needs.release.outputs.version }}.exe
asset_content_type: application/octet-stream