-
Notifications
You must be signed in to change notification settings - Fork 5
93 lines (83 loc) · 3.14 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
name: Release
on:
push:
tags:
- 'v*.*.*'
jobs:
release:
runs-on: ubuntu-latest
name: Create release and update documentation
steps:
- name: Set variables
id: vars
run: |
echo "::set-output name=tag::${GITHUB_REF#refs/*/}"
echo "::set-output name=target_branch::gh-pages"
echo "::set-output name=latest_name::latest"
- name: Check out main branch
uses: actions/checkout@v2
with:
persist-credentials: false
- name: Check out documentation branch
uses: actions/checkout@v2
with:
ref: ${{ steps.vars.outputs.target_branch }}
path: ${{ steps.vars.outputs.target_branch }}
persist-credentials: false
- name: Cache nimble
id: cache-nimble
uses: actions/cache@v2
with:
path: ~/.nimble
key: ${{ runner.os }}-nimble
if: runner.os != 'Windows'
- name: Set up Nim
uses: jiro4989/setup-nim-action@v1
with:
nim-version: stable
- name: Build documentation
run: nimble docs
- name: Generate landing page
run: |
nim r --hints:off --verbosity:0 $GITHUB_WORKSPACE/docsrc/build_index.nim $GITHUB_WORKSPACE
- name: Copy documentation
run: |
rm -rf ./${{ steps.vars.outputs.latest_name }}
cp -r $GITHUB_WORKSPACE/docs ./${{ steps.vars.outputs.latest_name }}
cp -r $GITHUB_WORKSPACE/docs ./${{ steps.vars.outputs.tag }}
working-directory: ./${{ steps.vars.outputs.target_branch }}
- name: Deploy documentation
uses: JamesIves/github-pages-deploy-action@3.7.1
with:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
BRANCH: ${{ steps.vars.outputs.target_branch }}
FOLDER: ${{ steps.vars.outputs.target_branch }}
GIT_CONFIG_NAME: GitHub Action
GIT_CONFIG_EMAIL: action@github.com
COMMIT_MESSAGE: 'docs: update documentation to ${{ steps.vars.outputs.tag }}'
# this is necessary to make retrieving the previous tag possible
# without it, the previous tag is somehow the same as the current tag
# this seems to be because of actions/checkout@2
- name: Clean git tags
run: git fetch --prune --unshallow --tags --force
- name: Install fugitive
run: nimble install -y fugitive
- name: Create changelog
id: changelog
run: |
TAG=${{ steps.vars.outputs.tag }}
LAST_TAG=$(git describe --abbrev=0 --tags $(git rev-list --tags --skip=1 --max-count=1))
echo 'CHANGELOG_BODY<<EOF' >> $GITHUB_ENV
fugitive changelog --tag:${TAG} --last-tag:${LAST_TAG} --no-anchor --no-title --no-divider >> $GITHUB_ENV
echo 'EOF' >> $GITHUB_ENV
env:
GITHUB_TOKEN: ${{ github.token }}
- name: Create release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ steps.vars.outputs.tag }}
release_name: ${{ steps.vars.outputs.tag }}
body: ${{ env.CHANGELOG_BODY }}