Skip to content
Merged
41 changes: 41 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: Move floating version tags

# When a release is published with a full semver tag (e.g. v2.3.1), move the
# floating major (v2) and minor (v2.3) tags to point at it, so consumers
# pinned to `@v2` or `@v2.3` get the new release. Prereleases (e.g.
# v2.4.0-rc.1) are skipped, so you can publish them without shipping to
# everyone on `@v2`.

on:
release:
types: [published]

permissions:
contents: write

jobs:
retag:
runs-on: ubuntu-latest
if: ${{ !github.event.release.prerelease }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Update major and minor tags
run: |
set -euo pipefail
TAG="${GITHUB_REF_NAME}" # e.g. v2.3.1
# Only move tags for plain vMAJOR.MINOR.PATCH releases.
if [[ ! "$TAG" =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
echo "::notice::Tag '$TAG' is not a vX.Y.Z release; not moving floating tags."
exit 0
fi
MAJOR="${TAG%%.*}" # v2
MINOR="${TAG%.*}" # v2.3
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
git tag -f "$MAJOR" "$TAG"
git tag -f "$MINOR" "$TAG"
git push -f origin "$MAJOR" "$MINOR"
echo "Moved $MAJOR and $MINOR -> $TAG"
58 changes: 58 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
name: Test action

on:
push:
branches:
- main
pull_request:
workflow_dispatch:

# Saving/pulling is disabled below, so no Calkit/DVC token (and no OIDC) is
# needed and the default read-only token is sufficient.
permissions:
contents: read

jobs:
run-examples:
name: ${{ matrix.example.repo }}
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
# Each entry clones a real Calkit example project and runs a single
# lightweight stage so the action's environment setup is exercised
# without building the heavy `tex` (texlive/texlive Docker) env that
# these projects use for their paper-build stages. `target` must be a
# stage whose environment is the one we want to verify got installed.
# To cover another kind, add an example repo + a cheap target here.
example:
- repo: example-basic
target: collect-data # uses the `py` (uv-venv) environment
verify: uv --version
- repo: example-julia
target: run-script # uses the `main` (julia) environment
verify: julia --version
steps:
# The composite action's steps run in $GITHUB_WORKSPACE, and it reads
# ./calkit.yaml from there, so the example project must be the workspace
# root. The workspace is empty at job start, so cloning into "." works;
# we then check this action out into a subdirectory and reference it
# locally via `uses: ./_action`.
- name: Clone example project
run: git clone --depth 1 "https://github.com/calkit/${{ matrix.example.repo }}.git" .

- name: Check out this action
uses: actions/checkout@v4
with:
path: _action

- name: Run Calkit action
uses: ./_action
with:
save: "false"
pull_dvc: "false"
cache_dvc: "false"
run_args: ${{ matrix.example.target }}

- name: Verify expected tooling was installed
run: ${{ matrix.example.verify }}
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ A GitHub Action to run a Calkit project's pipeline and optionally save results

The example workflow below shows how to run a Calkit project, saving results.
Note the permissions, concurrency, and checkout options.
The action detects required environment kinds from `calkit.yaml` and sets up
needed tooling (for example Calkit via `uv`, Julia, Pixi, Conda, R, MATLAB,
and Docker Buildx) before running.

<!-- Do not edit the snippet below since it is automatically populated -->
<!-- snippet:example.yml:start -->
Expand Down Expand Up @@ -44,10 +47,7 @@ jobs:
run: |
git config user.name github-actions[bot]
git config user.email 41898282+github-actions[bot]@users.noreply.github.com
- name: Setup uv
uses: astral-sh/setup-uv@v5
- name: Install Calkit
run: uv tool install calkit-python
# This action automatically runs necessary setup steps based on environments
- name: Run Calkit
uses: calkit/run-action@v2
```
Expand Down
Loading
Loading