Skip to content

Commit 6ac3629

Browse files
committed
ci: setup workflows
1 parent eb1160a commit 6ac3629

File tree

4 files changed

+151
-0
lines changed

4 files changed

+151
-0
lines changed

.github/workflows/ci.yml

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
name: Test, Build, and Release
2+
on:
3+
push:
4+
branches: [main]
5+
tags: ["v*"]
6+
pull_request:
7+
branches: [main]
8+
workflow_dispatch:
9+
10+
jobs:
11+
pre_build:
12+
permissions:
13+
actions: write
14+
contents: read
15+
name: Duplicate Actions Detection
16+
runs-on: ubuntu-latest
17+
outputs:
18+
should_skip: ${{ steps.skip_check.outputs.should_skip }}
19+
steps:
20+
- id: skip_check
21+
uses: fkirc/skip-duplicate-actions@v5
22+
with:
23+
cancel_others: "true"
24+
25+
# test:
26+
# needs: [pre_build]
27+
# runs-on: ubuntu-latest
28+
# steps:
29+
# - name: Checkout
30+
# uses: actions/checkout@v4
31+
32+
# - name: Install tools
33+
# uses: taiki-e/install-action@v2
34+
# with:
35+
# tool: cargo-binstall,just
36+
# - name: Install more tools
37+
# run: |
38+
# cargo binstall tytanic -y
39+
40+
# - name: Run test suite
41+
# run: just test
42+
43+
build:
44+
needs: [pre_build]
45+
runs-on: ubuntu-latest
46+
steps:
47+
- name: Checkout
48+
uses: actions/checkout@v4
49+
50+
- name: Install tools
51+
uses: taiki-e/install-action@just
52+
53+
- name: Setup typst
54+
uses: typst-community/setup-typst@v3
55+
56+
- name: Build package
57+
run: |
58+
just doc
59+
just package out
60+
61+
- name: Upload artifacts
62+
uses: actions/upload-artifact@v4
63+
with:
64+
name: radishom
65+
path: out/**/*
66+
67+
release:
68+
runs-on: ubuntu-latest
69+
needs: [build]
70+
if: success() && startsWith(github.ref, 'refs/tags/')
71+
permissions:
72+
contents: write
73+
steps:
74+
- uses: actions/checkout@v4
75+
with:
76+
submodules: recursive
77+
- uses: actions/download-artifact@v4
78+
with:
79+
path: artifacts
80+
- name: Display structure of downloaded files
81+
run: ls -R artifacts
82+
- uses: ncipollo/release-action@v1
83+
with:
84+
token: ${{ secrets.GITHUB_TOKEN }}
85+
artifacts: "artifacts/*/*"
86+
allowUpdates: true
87+
omitBodyDuringUpdate: true
88+
omitDraftDuringUpdate: true
89+
omitNameDuringUpdate: true
90+
omitPrereleaseDuringUpdate: true
91+
bodyFile: CHANGELOG.md

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
/out
2+
/target
3+
4+
*.pdf

justfile

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
export TYPST_ROOT := justfile_directory()
2+
3+
4+
default:
5+
@just --list
6+
7+
doc:
8+
typst c docs/manual.typ -f pdf
9+
10+
# test:
11+
# tt run --no-fail-fast
12+
13+
# package the library into the specified destination folder
14+
package target="out":
15+
./scripts/package.sh "{{target}}"

scripts/package.sh

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
#!/bin/bash
2+
3+
# Check if target directory argument is provided
4+
if [ -z "$1" ]; then
5+
echo "Usage: $0 <target-directory>"
6+
exit 1
7+
fi
8+
9+
TARGET_DIR="$1"
10+
11+
12+
# If the target directory exists, remove its contents; otherwise, create it.
13+
if [ -d "$TARGET_DIR" ]; then
14+
rm -rf "$TARGET_DIR"/*
15+
else
16+
mkdir -p "$TARGET_DIR"
17+
fi
18+
19+
# Create a temporary directory for packaging
20+
TEMP_DIR=$(mktemp -d) || { echo "Failed to create temp directory"; exit 1; }
21+
22+
# Copy files and directories into the temp directory
23+
cp --parents examples/*.svg "$TEMP_DIR" 2>/dev/null
24+
cp --parents -r src "$TEMP_DIR" 2>/dev/null
25+
cp --parents LICENSE "$TEMP_DIR" 2>/dev/null
26+
cp --parents README.md "$TEMP_DIR" 2>/dev/null
27+
cp --parents typst.toml "$TEMP_DIR" 2>/dev/null
28+
29+
# Create a 7z archive of the temporary directory.
30+
# Archive name will be based on the temporary directory name.
31+
ARCHIVE_NAME="$TARGET_DIR/radishom.7z"
32+
33+
7z a "$ARCHIVE_NAME" "$TEMP_DIR"/*
34+
35+
# Remove the temporary directory
36+
rm -rf "$TEMP_DIR"
37+
38+
# Copy docs/manual.pdf directly to the target directory
39+
cp docs/manual.pdf "$TARGET_DIR" 2>/dev/null
40+
41+
echo "Packaging complete. Archive saved at $ARCHIVE_NAME"

0 commit comments

Comments
 (0)