Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: Release PR

on:
workflow_dispatch:
schedule:
# TODO: Friday release instead? :o
- cron: "0 9 * * 1" # Create releases 9AM on a monday

jobs:
release-pr:
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v5
with:
fetch-depth: 0 # fetch all commits
tags: true # fetch all tags

- name: Set up Git
run: |
git config --global user.name "github-actions[bot]"
git config --global user.email "github-actions[bot]@users.noreply.github.com"

- name: Install dependencies
run: |
sudo apt update
sudo apt install gh -y
cargo install git-cliff --locked

- name: Authenticate GitHub CLI
run: gh auth login --with-token <<< "${{ secrets.GITHUB_TOKEN }}"

- name: Run release PR script
run: ./scripts/create-release.sh
20 changes: 16 additions & 4 deletions scripts/create-release.sh
Original file line number Diff line number Diff line change
@@ -1,20 +1,32 @@
#!/usr/bin/env bash
set -euo pipefail

TAG="$1"
BRANCH="release/v$TAG"

if ! command -v git-cliff >/dev/null; then
echo "git-cliff is not installed. Run: cargo install git-cliff"
exit 1
fi

# Fail fast if opam-publish isn't installed
if ! command -v gh >/dev/null; then
echo "github-clie is not installed."
echo "github-cli is not installed."
exit 1
fi

if [ $# -ge 1 ] && [ -n "$1" ]; then
TAG="$1"
else
git fetch --tags

LAST_TAG=$(git describe --tags --abbrev=0 || echo "v0.0.0")

IFS='.' read -r MAJOR MINOR PATCH <<< "${LAST_TAG#v}"

MINOR=$((MINOR + 1))

TAG="$MAJOR.$MINOR.$PATCH"
fi

BRANCH="release/v$TAG"
git switch -c $BRANCH
git-cliff -c cliff.toml -t $TAG -o CHANGES.md
git add CHANGES.md
Expand Down
Loading