Skip to content

Commit

Permalink
Restore build-script
Browse files Browse the repository at this point in the history
  • Loading branch information
tvdijen committed Feb 7, 2024
1 parent 7de4419 commit 5bf6da7
Show file tree
Hide file tree
Showing 3 changed files with 66 additions and 91 deletions.
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
lib/.gitkeep export-ignore
/bin export-ignore
95 changes: 4 additions & 91 deletions .github/workflows/build-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,78 +8,16 @@ on: # yamllint disable-line rule:truthy
- '*'
workflow_dispatch:

env:
HLJS_VERSION: 11.9.0
PAKO_VERSION: 2.1.0

jobs:
build-hljs:
name: Build dependencies
runs-on: [ubuntu-latest]
strategy:
fail-fast: false

steps:
- uses: actions/setup-node@v4
with:
node-version: 20

- uses: actions/checkout@v4
with:
repository: 'highlightjs/highlight.js'
ref: ${{ env.HLJS_VERSION }}

- name: Custom build Highlight.js
run: |
npm install --package-lock-only
npm clean-install
npm run build
node tools/build.js xml properties http
- name: 'Upload Hightlight.js build'
uses: actions/upload-artifact@v4
with:
name: hljs
path: build/highlight.min.js
retention-days: 1

build-pako:
name: Build dependencies
build:
name: Build release
runs-on: [ubuntu-latest]
strategy:
fail-fast: false

steps:
- uses: actions/setup-node@v4
with:
node-version: 20

- uses: actions/checkout@v4
with:
repository: 'nodeca/pako'
ref: "${{ env.PAKO_VERSION }}"

- name: Custom build Pako
run: |
npm install --package-lock-only
npm clean-install
npm run build
- name: 'Upload Pako build'
uses: actions/upload-artifact@v4
with:
name: pako
path: dist/pako_inflate.min.js
retention-days: 1

build:
name: Build release
runs-on: [ubuntu-latest]
needs: [build-hljs, build-pako]
strategy:
fail-fast: false

steps:
- uses: actions/checkout@v4
with:
token: ${{ secrets.SAMLTRACER_BUILD_TOKEN }}
Expand All @@ -91,40 +29,15 @@ jobs:
# Without fetching, we might miss new tags due to caching in Github Actions
run: git fetch --all

- uses: actions/download-artifact@v4
with:
name: hljs
path: lib/

- uses: actions/download-artifact@v4
with:
name: pako
path: lib/

- uses: geekyeggo/delete-artifact@v4
with:
name: |
hljs
pako
- name: Run build-script
run: bin/build.sh

# Store the version, stripping any v-prefix
- name: Write release version
run: |
TAG="${{ github.ref_name }}"
echo "VERSION=${TAG#v}" >> "$GITHUB_ENV"
- name: Clean release
run: |
grep export-ignore .gitattributes | cut -d ' ' -f 1 | while IFS= read -r line
do
rm -rf "$line"
done
rm -rf .git
- name: Build release
run: |
zip -r /tmp/samltracer.zip *
- name: Save release
uses: actions/upload-artifact@v4
with:
Expand Down
61 changes: 61 additions & 0 deletions bin/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
#!/bin/bash

set -e

CWD="$(pwd)"

HLJS_VERSION=11.9.0
PAKO_VERSION=2.1.0

if [ -n "$1" ]; then
RELEASE="tags/$1"
TARGET="/tmp/$1.zip"
else
RELEASE="HEAD"
TARGET="/tmp/samltracer.zip"
fi

if ! git rev-parse --verify "$RELEASE" >/dev/null 2>&1; then
echo "Invalid revision: $RELEASE" >&2
exit 1
fi

# Build Highlight.js
HLJS=$(mktemp -d)
cd "$HLJS"
git clone -b "$HLJS_VERSION" https://github.com/highlightjs/highlight.js.git
cd highlight.js

npm install --package-lock-only
npm clean-install
npm run build
node tools/build.js xml properties http

# Build Pako
PAKO=$(mktemp -d)
cd "$PAKO"
git clone -b "$PAKO_VERSION" https://github.com/nodeca/pako.git
cd pako

npm install --package-lock-only
npm clean-install
npm run build

DEST=$(mktemp -d)
cd "$CWD"
cp -R * "$DEST/"

# Copy dependencies
cp "$HLJS/highlight.js/build/highlight.min.js" "$DEST/lib/"
cp "$PAKO/pako/dist/pako_inflate.min.js" "$DEST/lib/"

rm -rf "$DEST/bin"

git archive --format tar "$RELEASE" | (cd "$DEST"; tar xv)

cd "$DEST"

zip -r "$TARGET" *

cd /
#rm -r "$DEST"

0 comments on commit 5bf6da7

Please sign in to comment.