Compare commits
No commits in common. "d5a176a60ab2be859783c47c9eadeb41fdd91746" and "9e3567a0df3159c4314da95d442ccc00fdff1698" have entirely different histories.
d5a176a60a
...
9e3567a0df
|
@ -0,0 +1,16 @@
|
||||||
|
name: GitHub Action for checking typst compilation
|
||||||
|
run-name: Performing Typst compilation
|
||||||
|
on: [push]
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
run-ci-linux:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Check out repository code
|
||||||
|
uses: actions/checkout@v3
|
||||||
|
- name: Setup Nix
|
||||||
|
uses: cachix/install-nix-action@v27
|
||||||
|
with:
|
||||||
|
nix_path: nixpkgs=channel:nixos-unstable
|
||||||
|
- name: Run CI
|
||||||
|
run: nix-shell --run ./run-ci.sh
|
|
@ -1,13 +1,12 @@
|
||||||
name: Build'n check on ${{ github.event.head_commit.message }}
|
name: release
|
||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
branches:
|
tags:
|
||||||
- main
|
- 'v*.*.*'
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build:
|
release:
|
||||||
name: Check Template and Build example
|
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- name: Check out repository code
|
- name: Check out repository code
|
||||||
|
@ -16,49 +15,16 @@ jobs:
|
||||||
uses: cachix/install-nix-action@v27
|
uses: cachix/install-nix-action@v27
|
||||||
with:
|
with:
|
||||||
nix_path: nixpkgs=channel:nixos-unstable
|
nix_path: nixpkgs=channel:nixos-unstable
|
||||||
- name: Stylecheck
|
- name: Run CI
|
||||||
run: nix-shell --run "./run-fmt.sh --check src/lib.typ"
|
run: nix-shell --run ./run-ci.sh
|
||||||
- id: build
|
|
||||||
name: Build
|
|
||||||
run: |
|
|
||||||
nix-shell --run ./run-ci.sh
|
|
||||||
- name: Upload artifact
|
|
||||||
id: artifact-upload
|
|
||||||
uses: actions/upload-artifact@v3
|
|
||||||
with:
|
|
||||||
name: example-document
|
|
||||||
path: ${{ github.workspace }}/example.pdf
|
|
||||||
if-no-files-found: error
|
|
||||||
retention-days: 1
|
|
||||||
- name: Output artifact ID
|
|
||||||
run: echo 'Artifact ID is ${{ steps.artifact-upload.outputs.artifact-id }}'
|
|
||||||
release:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
needs: build
|
|
||||||
if: startsWith(github.ref, 'refs/tags/')
|
|
||||||
permissions:
|
|
||||||
contents: write
|
|
||||||
steps:
|
|
||||||
- name: Check out repository code
|
|
||||||
uses: actions/checkout@v3
|
|
||||||
- name: Setup go
|
- name: Setup go
|
||||||
uses: actions/setup-go@v4
|
uses: https://github.com/actions/setup-go@v4
|
||||||
with:
|
with:
|
||||||
go-version: '>=1.20.1'
|
go-version: '>=1.20.1'
|
||||||
- name: Download Artifcat
|
- name: Create release
|
||||||
id: download
|
id: create-release
|
||||||
uses: actions/download-artifact@v3
|
uses: https://gitea.com/actions/release-action@main
|
||||||
with:
|
with:
|
||||||
name: example-document
|
files: |-
|
||||||
path: ${{ github.workspace }}/Example.pdf
|
example.pdf
|
||||||
- name: 'Artifact Download Path'
|
api_key: '${{secrets.RELEASE_TOKEN}}'
|
||||||
run: echo ${{ steps.download.outputs.download-path }}
|
|
||||||
- name: Prepare Release
|
|
||||||
run: echo ${{ github.sha }} > Release.txt
|
|
||||||
- name: Release ${{ GITHUB_REF_NAME }}
|
|
||||||
uses: softprops/action-gh-release@v2
|
|
||||||
with:
|
|
||||||
files: |
|
|
||||||
Example.pdf
|
|
||||||
Release.txt
|
|
||||||
LICENSE
|
|
||||||
|
|
48
run-ci.sh
48
run-ci.sh
|
@ -1,3 +1,49 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
typst compile template/main.typ --root . --font-path fonts example.pdf
|
function log() {
|
||||||
|
local timestamp=$(date +"%Y-%m-%d %H:%M:%S")
|
||||||
|
echo "$1 at $timestamp: $2"
|
||||||
|
}
|
||||||
|
|
||||||
|
function abort() {
|
||||||
|
log "ERROR" "test case $1 has failed"
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
|
||||||
|
function print-box() {
|
||||||
|
printf "\\n"
|
||||||
|
echo ".----------------------------------------------------------------."
|
||||||
|
printf "| %-62s |\\n" "$1"
|
||||||
|
echo "'----------------------------------------------------------------'"
|
||||||
|
}
|
||||||
|
|
||||||
|
function enter-section() {
|
||||||
|
print-box "$1"
|
||||||
|
|
||||||
|
log "INFO" "running task in section $1: $2"
|
||||||
|
log "INFO" "section output following..."
|
||||||
|
printf "\\n"
|
||||||
|
|
||||||
|
eval "$2"
|
||||||
|
exit_status=$?
|
||||||
|
|
||||||
|
if [ "$3" == "should fail" ]; then
|
||||||
|
log "INFO" "expected to fail..."
|
||||||
|
if [ $exit_status -eq 0 ]; then
|
||||||
|
abort "command: $2 failed in section: $1 with: $exit_status"
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
log "INFO" "expected to pass..."
|
||||||
|
if [ ! $exit_status -eq 0 ]; then
|
||||||
|
abort "command: $2 failed in section: $1 with: $exit_status"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
printf "\\n"
|
||||||
|
log "INFO" "section $1 completed successfully"
|
||||||
|
}
|
||||||
|
|
||||||
|
enter-section "Typstyle checking" "./run-fmt.sh --check src/lib.typ" 0
|
||||||
|
enter-section "Compiling template..." "typst compile template/main.typ --root . --font-path fonts example.pdf"
|
||||||
|
|
||||||
|
log "INFO" "CI completed successfully"
|
||||||
|
|
Loading…
Reference in New Issue