Skip to content

[release]

[release] #4

Workflow file for this run

# Triggered by a push with [release] in the title on this repository, this
# workflow builds and publishes a snap to the Snap Store.
#
# The Typst Ref name is stored in the `target-tag` file at the repository root.
name: Push
on:
push:
branches:
- main
jobs:
buildSnap:
runs-on: ubuntu-latest
if: contains(github.event.head_commit.message, '[release]')
steps:
- uses: actions/checkout@v4
- name: Read the target tag and store it in the step's output
id: read-tag
run: echo "channel=$(cat target-tag)" >> "$GITHUB_OUTPUT"
- name: Decide the channel based on the tag
id: decide-channel
env:
TAG: ${{ steps.read-tag.outputs.tag }}
run: |
# Choose the channel based on the tag. If the tag does not contain a
# hyphen but does contain a "v" prefix, it is a stable release. If the
# tag contains the string "rc", it is a "candidate" release. If the
# tag contains the string "beta", it is a "beta" release and otherwise
# it is an "edge" release.
if [[ ! $TAG =~ "-" && $TAG =~ "v" ]]; then
echo "channel=stable" >> "$GITHUB_OUTPUT"
elif [[ $TAG =~ "rc" ]]; then
echo "channel=candidate" >> "$GITHUB_OUTPUT"
elif [[ $TAG =~ "beta" ]]; then
echo "channel=beta" >> "$GITHUB_OUTPUT"
else
echo "channel=edge" >> "$GITHUB_OUTPUT"
fi
- name: Echo the channel
env:
TAG: ${{ steps.read-tag.outputs.tag }}
CHANNEL: ${{ steps.decide-channel.outputs.channel }}
run: echo "Building $TAG for the $CHANNEL channel"
- name: Populate the snapcraft.yaml
env:
TAG: ${{ steps.read-tag.outputs.tag }}
run: ./template.sh $TAG
- uses: snapcore/action-build@v1
id: build
- uses: snapcore/action-publish@v1
env:
SNAPCRAFT_STORE_CREDENTIALS: ${{ secrets.STORE_LOGIN }}
with:
snap: ${{ steps.build.outputs.snap }}
release: ${{ steps.decide-channel.outputs.channel }}