-
Notifications
You must be signed in to change notification settings - Fork 0
83 lines (80 loc) · 2.54 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
name: Build
on:
push:
branches:
- 'main'
paths:
- '*.py'
- '*.md'
- 'articles/**'
- 'blog/**'
- 'docker/**'
- 'tests/**'
- 'requirements.txt'
permissions:
contents: write
jobs:
Build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
token: ${{ secrets.PAT }}
- name: Get Latest Version
id: latest
uses: gregziegan/[email protected]
- name: Calculate Next Version
id: calculate
uses: paulhatch/[email protected]
with:
version_format: "${major}.${minor}.${patch}"
- name: Determine Next Version
if: ${{ contains(steps.latest.outputs.name, '.') }}
id: version
uses: haya14busa/action-cond@v1
with:
cond: ${{ contains(steps.latest.outputs.name, '.') }}
if_true: ${{ steps.calculate.outputs.version }}
if_false: '0.0.1'
- name: Remove Leading "v" from Latest Version
if: ${{ contains(steps.latest.outputs.name, '.') }}
id: latest_clean
run: |
export version=$(echo ${{ steps.latest.outputs.name }} | sed 's/^v//')
echo ::set-output name=name::$version
- name: Update Version in Files
if: ${{ contains(steps.latest.outputs.name, '.') }}
uses: datamonsters/replace-action@v2
with:
files: 'blog/config.py'
replacements: "${{ steps.latest_clean.outputs.name }}=${{ steps.version.outputs.value }}"
- name: File Save Delay
uses: jakejarvis/wait-action@master
with:
time: '2s'
- name: Commit Version Changes
uses: stefanzweifel/git-auto-commit-action@v5
with:
commit_message: "[skip ci] Update version to v${{ steps.version.outputs.value }}"
- name: Setup Python
uses: actions/setup-python@v4
with:
python-version: '3.12'
- name: Install Dependencies
run: |
python -m pip install -r requirements.txt
- name: Generate Distribution
run: |
python -m blog.generate
cd dist
zip -r ../blog-v${{ steps.version.outputs.value }}.zip *
- name: Create Release
uses: ncipollo/[email protected]
with:
allowUpdates: true
artifacts: blog-v${{ steps.version.outputs.value }}.zip
draft: false
makeLatest: true
tag: v${{ steps.version.outputs.value }}
name: v${{ steps.version.outputs.value }}