-
Notifications
You must be signed in to change notification settings - Fork 0
137 lines (123 loc) · 4.29 KB
/
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
name: Create release
on:
workflow_dispatch:
schedule:
# * is a special character in YAML so you have to quote this string
- cron: "0 0 * * *"
jobs:
create-tag:
name: Check if new commit
runs-on: ubuntu-latest
outputs:
skip: ${{ steps.skip.outputs.skip }}
tag: ${{ steps.create-tag-name.outputs.tag }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Should it run?
id: skip
run: |
# Resolve the current tag into it's commit to be able to directly compare
# with HEAD. This means that a manual tag such as "version 1.0" will not
# cause the CI job to create a new tag pointing to the same commit.
PREVTAGCOMMIT_UNSANITIZED="$(git tag --sort=creatordate | tail -n1)"
PREVTAGCOMMIT_SANITIZED="$(git rev-list -n 1 $PREVTAGCOMMIT_UNSANITIZED)"
PREVTAGCOMMIT="$(git rev-parse --short $PREVTAGCOMMIT_SANITIZED)"
CURRENTCOMMIT="$(git rev-parse --short HEAD)"
if [ "$PREVTAGCOMMIT" == "$CURRENTCOMMIT" ]; then
echo "Tags are the same ($PREVTAGCOMMIT != $CURRENTCOMMIT), skipping future steps"
echo "skip=true" >> $GITHUB_OUTPUT
else
echo "Tags are not the same ($PREVTAGCOMMIT != $CURRENTCOMMIT). Continuing."
echo "skip=false" >> $GITHUB_OUTPUT
fi
- name: Set tag name
id: create-tag-name
if: steps.skip.outputs.skip == 'false'
run: |
v=${GITHUB_REF##*/}
echo "Version: $v"
echo "tag=$(date '+%F')-$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT
setup-envs:
name: Generate data for release
runs-on: ubuntu-latest
needs: create-tag
if: needs.create-tag.outputs.skip == 'false'
outputs:
release_body: ${{ steps.release.outputs.release_body }}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Generate latest changelog
uses: orhun/git-cliff-action@v3
id: git-cliff-latest
with:
args: -vv --latest --strip header
env:
OUTPUT: CHANGELOG.md
- name: Set the release body
id: release
continue-on-error: true
shell: bash
run: |
r=$(cat ${{ steps.git-cliff-latest.outputs.changelog }})
r="$(printf "$r" | tail -n +3)"
r="${r//'%'/'%25'}"
r="${r//$'\n'/'%0A'}"
r="${r//$'\r'/ &&
build:
name: Build document
runs-on: ubuntu-latest
needs: [create-tag, setup-envs]
if: needs.create-tag.outputs.skip == 'false'
steps:
- uses: actions/checkout@v4
- uses: satackey/[email protected]
continue-on-error: true
name: Enable docker cache
- uses: xu-cheng/latex-action@v3
name: "Compile document 1/2"
with:
root_file: release.tex
args: -synctex=1 -interaction=nonstopmode -file-line-error -pdf
- uses: xu-cheng/latex-action@v3
name: "Compile document 2/2"
with:
root_file: progress.tex
args: -synctex=1 -interaction=nonstopmode -file-line-error -pdf
pre_compile: "bibtex release"
post_compile: "latexmk -c"
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: release-pdf-release
path: ./release.pdf
publish-github:
name: Publish on GitHub
runs-on: ubuntu-latest
needs: [create-tag, setup-envs, build]
if: needs.create-tag.outputs.skip == 'false'
steps:
- name: Checkout
if: ${{ !env.ACT }}
uses: actions/checkout@v4
- name: Download artifacts
if: ${{ !env.ACT }}
id: download
uses: actions/download-artifact@v4
with:
name: release-pdf-release
path: release-pdf-release
- name: Upload the release
if: ${{ !env.ACT }}
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
tag: ${{ needs.create-tag.outputs.tag }}
file: ${{steps.download.outputs.download-path}}/release.pdf
asset_name: $tag.pdf
release_name: "${{ needs.create-tag.outputs.tag }}"
body: "${{ needs.setup-envs.outputs.release_body }}"