That's a very nerdy topic, maybe overkill, maybe also off-topic on this forum (if so, sorry about that!), but I did a CI on GitHub allowing to automatically generate the archive to drop on CTAN for a package submission (or update).
1 Answer
This file sets the CI up, here it is done for the library tikz-shieds, but it can be easily adapted to any package :)
name: Automated testing
on:
push:
branches:
- main
tags:
- 'v*'
pull_request:
branches:
- '*'
jobs:
artifact:
name: Test and create artifact
runs-on: ubuntu-latest
steps:
- name: checkout code
uses: actions/checkout@v5
- name: Compile documentation document
uses: xu-cheng/latex-action@v4
with:
root_file: |
tests/test-0.tex
# include here all the test files you want
tikz-shields-doc.tex # and the documentation
latexmk_shell_escape: true
post_compile: "latexmk -c; rm -rf _minted*"
- name: Upload Artifact
uses: actions/upload-artifact@v4
with:
name: tikz-shields
path: |
./tikz-shields.sty
./tikz-shields-doc.tex
./tikz-shields-doc.pdf
./README.md
./LICENSE
./doc/**
!./.git*
!./.gitignore
release:
needs: [artifact]
runs-on: ubuntu-latest
name: Create Release
if: startsWith(github.ref, 'refs/tags/v')
steps:
- name: Download artifact
uses: actions/download-artifact@v4
with:
path: ${{ github.workspace }}/artifact
- name: Create archive
run: |
temp_dir=$(mktemp -d)
cd artifact
zip -r "${temp_dir}/tikz-shields.zip" ./
cd ..
mv "${temp_dir}/tikz-shields.zip" ./
rm -rf "${temp_dir}"
- name: Create Release
id: create_release
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ github.ref }}
name: Release ${{ github.ref }}
draft: true
prerelease: false
token: ${{ secrets.GITHUB_TOKEN }}
files: tikz-shields.zip
Some notes:
- In step
Compile documentation document, the documentation is compiled, as well as various tests that can be added. - The step
Upload Artifactgenerates an archive that contains only the files necessary for the upload on CTAN: the sty file, the documentation (the source file as well as the compiled one), and theREADMEfile. Note here that files are present in the directorydoc.
After each commit to the main branch (or in another branch to which a pull request is open), the CI will be triggered, and this archive will be available as an artifact (with a few days of retention).
When you want to create a new version of the package, you just need to create a tag (git tag v1.0) and push it (git push then git push --tags), then the CI will create a draft release that can be manually published afterwards.
It contains the archive that can be sent to CTAN (example here).
You also need to give the permissions to the workflow so it can create the release. To do so, on GitHub, go to Settings > Action > General > Workflow permissions and check Read and write permissions.
The full pipeline for the example I used is available here: https://github.com/thomas-saigre/tikz-shields/blob/main/.github/workflows/ci.yml It may be updated in the future, but what I described above has worked well!
-
1Does it also automatically update the date/version in each file, so that they all agree?rallg– rallg2025-10-19 00:47:12 +00:00Commented Oct 19 at 0:47
-
You're right, it doesn't. And so sty the file actually deployed as v1.0 of my package still has v0.1. Thanks for spotting it, I'll try to find a fix to thisThomas– Thomas2025-10-19 09:56:31 +00:00Commented Oct 19 at 9:56
l3build ctanfor making ctan zips andl3build uploadwhich we use for some of the core latex bundles that have automatic ctan releases