-
Notifications
You must be signed in to change notification settings - Fork 0
115 lines (99 loc) · 3.47 KB
/
release.yml
File metadata and controls
115 lines (99 loc) · 3.47 KB
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
name: release
on:
workflow_dispatch:
push:
branches:
- master
jobs:
release:
runs-on: ubuntu-latest
permissions: write-all
name: Release
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Check version
id: version-check
run: |
VERSION=$(./scripts/is-newer-version.bash)
echo "version=${VERSION}" >> $GITHUB_OUTPUT
if [ "$VERSION" != "0" ]; then
echo "New version detected: $VERSION"
else
echo "No new version to release"
fi
- name: Push tag
if: steps.version-check.outputs.version != '0'
id: push-tag
run: |
tag="v${{ steps.version-check.outputs.version }}"
git config user.name "${GITHUB_ACTOR}"
git config user.email "${GITHUB_ACTOR}@users.noreply.github.com"
git tag -a "${tag}" -m "Release ${tag}"
git push origin "${tag}"
echo "tag_name=${tag}" >> $GITHUB_OUTPUT
- name: Checkout
if: steps.version-check.outputs.version != '0'
uses: actions/checkout@v4
- name: Setup Rust
if: steps.version-check.outputs.version != '0'
uses: MatteoH2O1999/setup-rust@v1
- name: Cache Rust dependencies
if: steps.version-check.outputs.version != '0'
uses: Swatinem/rust-cache@v2
with:
cache-on-failure: "true"
- name: Build project
if: steps.version-check.outputs.version != '0'
run: cargo build --release
shell: bash
working-directory: ${{ github.action_path }}
- name: Generate minimized HTML
if: steps.version-check.outputs.version != '0'
run: cargo run --release -- index.html
shell: bash
working-directory: ${{ github.action_path }}
- name: Copy files
if: steps.version-check.outputs.version != '0'
run: |
mkdir -p ../release
cp -v index.html ../release/
cp -v index.min.html ../release/
cp -v index.allinone.html ../release/
cp -v index.allinone.min.html ../release/
# Misc
cp -v LICENSE ../release/
cp -v README.md ../release/
cp -v README_EN.md ../release/
cp -v CONTRIBUTING.md ../release/
cp -v CNAME ../release/
cp -rv doc ../release/
cp -rv scripts ../release/
cp -rv src ../release/
shell: bash
working-directory: ${{ github.action_path }}
- name: Create release
if: steps.version-check.outputs.version != '0'
uses: ncipollo/release-action@v1
with:
generateReleaseNotes: true
tag: "v${{ steps.version-check.outputs.version }}"
artifacts: "../release/index.html,../release/index.min.html,../release/index.allinone.html,../release/index.allinone.min.html"
- name: Setup Pages
uses: actions/configure-pages@v4
- name: Upload artifact
uses: actions/upload-pages-artifact@v3
with:
path: '../release'
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4
- name: Delete tag
if: (cancelled() || failure()) && steps.push-tag.outputs.tag_name != ''
run: |
git config user.name "${GITHUB_ACTOR}"
git config user.email "${GITHUB_ACTOR}@users.noreply.github.com"
git push --delete origin "${{ steps.push-tag.outputs.tag_name }}"
git tag -d "${{ steps.push-tag.outputs.tag_name }}"