Skip to content

Commit 04b5585

Browse files
authored
Autobuild release when a tag is set (#87)
* Automate build-process
1 parent c4f5662 commit 04b5585

10 files changed

Lines changed: 125 additions & 393 deletions

File tree

.gitattributes

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
lib/.gitkeep export-ignore
2+
bin/ export-ignore
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
---
2+
3+
name: Build release
4+
5+
on: # yamllint disable-line rule:truthy
6+
push:
7+
tags:
8+
- '*'
9+
workflow_dispatch:
10+
11+
jobs:
12+
build:
13+
name: Build release
14+
runs-on: [ubuntu-latest]
15+
16+
steps:
17+
- uses: actions/setup-node@v4
18+
with:
19+
node-version: 20
20+
21+
- uses: actions/checkout@v4
22+
with:
23+
token: ${{ secrets.SAMLTRACER_BUILD_TOKEN }}
24+
ref: ${{ github.head_ref || github.ref_name }}
25+
# Full git history is needed to get a proper list of changed files within `super-linter`
26+
fetch-depth: 0
27+
28+
- name: Fetch changes
29+
# Without fetching, we might miss new tags due to caching in Github Actions
30+
run: git fetch --all
31+
32+
- name: Run build-script
33+
run: bin/build.sh
34+
35+
# Store the version, stripping any v-prefix
36+
- name: Write release version
37+
run: |
38+
TAG="${{ github.ref_name }}"
39+
echo "VERSION=${TAG#v}" >> "$GITHUB_ENV"
40+
41+
- name: Save release
42+
uses: actions/upload-artifact@v4
43+
with:
44+
name: release
45+
path: "/tmp/samltracer.zip"
46+
retention-days: 1
47+
48+
- name: Calculate SHA checksum
49+
run: sha256sum "/tmp/samltracer.zip"

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
samltracer.zip
1+
lib/*.js

.npmrc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# .npmrc
2+
engine-strict=true

bin/build.sh

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
#!/bin/bash
2+
3+
set -e
4+
5+
CWD="$(pwd)"
6+
7+
HLJS_VERSION=11.9.0
8+
PAKO_VERSION=2.1.0
9+
10+
if [ -n "$1" ]; then
11+
RELEASE="tags/$1"
12+
TARGET="/tmp/$1.zip"
13+
else
14+
RELEASE="HEAD"
15+
TARGET="/tmp/samltracer.zip"
16+
fi
17+
18+
if ! git rev-parse --verify "$RELEASE" >/dev/null 2>&1; then
19+
echo "Invalid revision: $RELEASE" >&2
20+
exit 1
21+
fi
22+
23+
# Build Highlight.js
24+
HLJS=$(mktemp -d)
25+
cd "$HLJS"
26+
git clone -b "$HLJS_VERSION" https://github.com/highlightjs/highlight.js.git
27+
cd highlight.js
28+
29+
npm install --package-lock-only
30+
npm clean-install
31+
npm run build
32+
node tools/build.js xml properties http
33+
34+
# Build Pako
35+
PAKO=$(mktemp -d)
36+
cd "$PAKO"
37+
git clone -b "$PAKO_VERSION" https://github.com/nodeca/pako.git
38+
cd pako
39+
40+
npm install --package-lock-only
41+
npm clean-install
42+
npm run build
43+
44+
DEST=$(mktemp -d)
45+
cd $CWD
46+
cp -R $CWD/. $DEST
47+
cd $DEST
48+
49+
# Copy dependencies
50+
cp "$HLJS/highlight.js/build/highlight.min.js" "$DEST/lib/"
51+
cp "$PAKO/pako/dist/pako_inflate.min.js" "$DEST/lib/"
52+
53+
# Clean release
54+
grep export-ignore .gitattributes | cut -d ' ' -f 1 | while IFS= read -r line
55+
do
56+
rm -rf "$line"
57+
done
58+
59+
git archive --format tar "$RELEASE" | (cd "$DEST"; tar xv)
60+
61+
cd "$DEST"
62+
63+
zip -r "$TARGET" *
64+
65+
cd /
66+
rm -rf "$DEST"
67+
rm -rf "$HLJS"
68+
rm -rf "$PAKO"

build.sh

Lines changed: 0 additions & 28 deletions
This file was deleted.

lib/.gitkeep

Whitespace-only changes.

lib/highlight.min.js

Lines changed: 0 additions & 359 deletions
This file was deleted.

lib/pako_inflate.min.js

Lines changed: 0 additions & 2 deletions
This file was deleted.

src/TraceWindow.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,12 +37,12 @@
3737
</div>
3838
</div>
3939

40+
<script type="text/javascript" src="../lib/pako_inflate.min.js"></script>
41+
<script type="text/javascript" src="../lib/highlight.min.js"></script>
4042
<script type="text/javascript" src="splitter.js"></script>
4143
<script type="text/javascript" src="hash.js"></script>
4244
<script type="text/javascript" src="SAMLTrace.js"></script>
4345
<script type="text/javascript" src="ui.js"></script>
4446
<script type="text/javascript" src="scrollableList.js"></script>
45-
<script type="text/javascript" src="../lib/pako_inflate.min.js"></script>
46-
<script type="text/javascript" src="../lib/highlight.min.js"></script>
4747
</body>
48-
</html>
48+
</html>

0 commit comments

Comments
 (0)