Skip to content

Commit 6665dd5

Browse files
committed
Add GitHub Actions workflow to publish releases
Add a workflow that will trigger on pushes to master which: * Builds the HTML version of the spec (using the Makefile) in a build directory * Moves the built HTML file as index.html to a versioned subdirectory of build * Moves the built HTML file as index.html to a 'latest' subdirectory of build * Switches to the 'gh-pages' branch and moves the conents of the build directory into the repo root * Builds an index of published versions as index.html at the root of the repo root * Commits the generated HTML files and pushes them to the gh-pages branch on GitHub Signed-off-by: Joshua Lock <[email protected]>
1 parent 8280e43 commit 6665dd5

File tree

1 file changed

+81
-0
lines changed

1 file changed

+81
-0
lines changed

.github/workflows/release.yml

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
name: Release specification
2+
on:
3+
workflow_dispatch:
4+
push:
5+
branches: master
6+
7+
jobs:
8+
make-release:
9+
name: Make and publish spec release
10+
runs-on: ubuntu-latest
11+
steps:
12+
- name: Set up Python
13+
uses: actions/setup-python@3105fb18c05ddd93efea5f9e0bef7a03a6e9e7df
14+
with:
15+
python-version: 3.x
16+
17+
- name: Find pip cache dir
18+
id: pip-cache
19+
run: echo "::set-output name=dir::$(pip cache dir)"
20+
21+
- name: pip cache
22+
uses: actions/cache@26968a09c0ea4f3e233fdddbafd1166051a095f6
23+
with:
24+
# Use the os dependent pip cache directory found above
25+
path: ${{ steps.pip-cache.outputs.dir }}
26+
# A match with 'key' counts as cache hit
27+
key: ${{ runner.os }}-pip-
28+
29+
- name: Clone main
30+
uses: actions/checkout@5a4ac9002d0be2fb38bd78e4b4dbde5606d7042f
31+
with:
32+
fetch-depth: 0
33+
34+
- name: Get previous version
35+
id: prevver
36+
run: |
37+
prev_version=`git tag | sort -V -r | head -n 1 | cut -c 2-`
38+
echo "::set-output name=prev_version::$(echo -n $prev_version)"
39+
40+
- name: Get version
41+
id: getver
42+
run: |
43+
spec_version=`grep -oP 'VERSION \K(\d+\.\d+\.\d+)' tuf-spec.md`
44+
echo "::set-output name=spec_version::$(echo -n $spec_version)"
45+
46+
- name: Make release
47+
if: steps.getver.outputs.spec_version != steps.prevver.outputs.prev_version
48+
uses: actions/create-release@0cb9c9b65d5d1901c1f53e5e66eaf4afd303e70e
49+
env:
50+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
51+
with:
52+
tag_name: v${{ steps.getver.outputs.spec_version }}
53+
release_name: v${{ steps.getver.outputs.spec_version }}
54+
body: Specification release v${{ steps.getver.outputs.spec_version }}
55+
56+
- name: Build specification
57+
if: steps.getver.outputs.spec_version != steps.prevver.outputs.prev_version
58+
run: |
59+
python -m pip install bikeshed
60+
mkdir build && cd build
61+
make -f ../Makefile release
62+
63+
- name: Switch branch
64+
if: steps.getver.outputs.spec_version != steps.prevver.outputs.prev_version
65+
uses: actions/checkout@5a4ac9002d0be2fb38bd78e4b4dbde5606d7042f
66+
with:
67+
ref: gh-pages
68+
clean: false
69+
70+
- name: Push generated specification
71+
if: steps.getver.outputs.spec_version != steps.prevver.outputs.prev_version
72+
run: |
73+
git config user.name "TUF Specification Automation"
74+
git config user.email [email protected]
75+
rm -fr latest
76+
mv build/* .
77+
rmdir build
78+
make index
79+
git add .
80+
git commit -m "Publish latest specification"
81+
git push

0 commit comments

Comments
 (0)