-
Notifications
You must be signed in to change notification settings - Fork 0
71 lines (60 loc) · 1.85 KB
/
publish.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
name: Release PDFs
on:
release:
types: [published]
workflow_dispatch:
jobs:
convert-markdown-to-pdf:
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Fetch tags
run: git fetch --tags
- name: Get latest tag
id: get_tag
run: |
latest_tag=$(git describe --tags `git rev-list --tags --max-count=1` || true)
echo "Latest tag: $latest_tag"
echo "::set-output name=tag::$latest_tag"
- name: Calculate new version
id: new_version
run: |
if [ -z "${{ steps.get_tag.outputs.tag }}" ]; then
# No tags found, set initial version
new_version="1.0.0"
else
# Parse the latest version
latest_version=${{ steps.get_tag.outputs.tag }}
IFS='.' read -r -a version_parts <<< "$latest_version"
major=${version_parts[0]}
minor=${version_parts[1]}
patch=${version_parts[2]}
# Increment the patch version
patch=$((patch+1))
new_version="$major.$minor.$patch"
fi
echo "New version: $new_version"
echo "::set-output name=version::$new_version"
- name: Create new tag
run: |
git tag ${{ steps.new_version.outputs.version }}
git push origin ${{ steps.new_version.outputs.version }}
- name: Build PDFs
run: make
- name: Install Hub CLI
run: sudo apt-get install -y hub
- name: Upload PDFs to GitHub Releases
run: |
set -x
cd build
assets=()
for asset in ./*.pdf; do
assets+=("-a" "$asset")
done
tag_name="${{ steps.new_version.outputs.version }}"
hub release create "${assets[@]}" -m "$tag_name" "$tag_name"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}