Skip to content

Commit 2a5d6d9

Browse files
committed
add release workflow
1 parent 888011f commit 2a5d6d9

File tree

1 file changed

+77
-0
lines changed

1 file changed

+77
-0
lines changed

.github/workflows/release.yml

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
name: Package and push to registry repo
2+
on:
3+
push:
4+
tags: [ v* ]
5+
6+
env:
7+
# the repository to which to push the release version
8+
# usually a fork of typst/packages (https://github.com/typst/packages/)
9+
# that you have push privileges to
10+
REGISTRY_REPO: author/typst-packages
11+
# the path within that repo where the "<name>/<version>" directory should be put
12+
# for the Typst package registry, keep this as is
13+
PATH_PREFIX: packages/preview
14+
15+
jobs:
16+
release:
17+
runs-on: ubuntu-latest
18+
steps:
19+
- name: Checkout
20+
uses: actions/checkout@v4
21+
22+
- name: Probe runner package cache
23+
uses: awalsh128/cache-apt-pkgs-action@v1
24+
with:
25+
packages: cargo
26+
version: 1.0
27+
28+
- name: Install just from crates.io
29+
uses: baptiste0928/cargo-install@v3
30+
with:
31+
crate: just
32+
33+
- name: Setup typst
34+
uses: typst-community/setup-typst@v3
35+
with:
36+
typst-version: latest
37+
38+
- name: Determine and check package metadata
39+
run: |
40+
. scripts/setup
41+
echo "PKG_NAME=${PKG_PREFIX}" >> "${GITHUB_ENV}"
42+
echo "PKG_VERSION=${VERSION}" >> "${GITHUB_ENV}"
43+
44+
if [[ "${GITHUB_REF_NAME}" != "v${VERSION}" ]]; then
45+
echo "package version ${VERSION} does not match release tag ${GITHUB_REF_NAME}" >&2
46+
exit 1
47+
fi
48+
49+
- name: Build package
50+
run: |
51+
just doc
52+
just package out
53+
54+
- name: Checkout package registry
55+
uses: actions/checkout@v4
56+
with:
57+
repository: ${{ env.REGISTRY_REPO }}
58+
token: ${{ secrets.REGISTRY_TOKEN }}
59+
path: typst-packages
60+
61+
- name: Release package
62+
run: |
63+
mkdir -p "typst-packages/${{ env.PATH_PREFIX }}/$PKG_NAME"
64+
mv "out/${PKG_NAME}/${PKG_VERSION}" "typst-packages/${{ env.PATH_PREFIX }}/${PKG_NAME}"
65+
rmdir "out/${PKG_NAME}"
66+
rmdir out
67+
68+
GIT_USER_NAME="$(git log -1 --pretty=format:'%an')"
69+
GIT_USER_EMAIL="$(git log -1 --pretty=format:'%ae')"
70+
71+
cd typst-packages
72+
git config user.name "${GIT_USER_NAME}"
73+
git config user.email "${GIT_USER_EMAIL}"
74+
git checkout -b "${PKG_NAME}-${PKG_VERSION}"
75+
git add .
76+
git commit -m "${PKG_NAME}:${PKG_VERSION}"
77+
git push --set-upstream origin "${PKG_NAME}-${PKG_VERSION}"

0 commit comments

Comments
 (0)