Skip to content

Commit dc47ab9

Browse files
committed
Automatic release scripts and workflow (#386)
1 parent 783c338 commit dc47ab9

File tree

4 files changed

+77
-3
lines changed

4 files changed

+77
-3
lines changed

.github/workflows/publish.yml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
name: opam-repository
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
8+
jobs:
9+
publish:
10+
runs-on: ubuntu-latest
11+
env:
12+
# allow opam depext to yes package manager prompts
13+
OPAMCONFIRMLEVEL: unsafe-yes
14+
steps:
15+
- name: Checkout
16+
uses: actions/checkout@v5
17+
with:
18+
fetch-depth: 0
19+
tags: true
20+
21+
- name: Setup OCaml
22+
uses: ocaml/setup-ocaml@v3
23+
with:
24+
ocaml-compiler: "5.3"
25+
26+
- name: Install dependencies
27+
run: opam install opam-publish
28+
29+
- name: Publish
30+
run: ./scripts/publish.sh

scripts/create-release.sh

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
#!/usr/bin/env bash
2+
set -euo pipefail
3+
4+
TAG="$1"
5+
BRANCH="release/v$TAG"
6+
7+
if ! command -v git-cliff >/dev/null; then
8+
echo "git-cliff is not installed. Run: cargo install git-cliff"
9+
exit 1
10+
fi
11+
12+
# Fail fast if opam-publish isn't installed
13+
if ! command -v gh >/dev/null; then
14+
echo "github-clie is not installed."
15+
exit 1
16+
fi
17+
18+
git switch -c $BRANCH
19+
git-cliff -c cliff.toml -t $TAG -o CHANGES.md
20+
git add CHANGES.md
21+
git commit -m "Release $TAG"
22+
git push -u origin $BRANCH
23+
24+
gh pr create \
25+
--base "main" \
26+
--head "$BRANCH" \
27+
--title "Release $TAG" \
28+
--body "Automated Release $TAG"

scripts/publish.sh

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#!/usr/bin/env bash
2+
set -euo pipefail
3+
4+
TAG="$(git describe --tags --exact-match 2>/dev/null || true)"
5+
6+
if [ -z "$TAG" ]; then
7+
echo "No tag on the current commit. Nothing to release."
8+
exit 0
9+
fi
10+
11+
echo "Found tag $TAG on HEAD. Releasing…"
12+
13+
# Remove pin depends which are not allowed in opam-repository
14+
sed -i '/^pin-depends:/,$d' smtml.opam
15+
16+
opam exec -- opam-publish \
17+
--tag="$TAG" \
18+
--no-confirmation \
19+
--no-browser

scripts/release.sh

Lines changed: 0 additions & 3 deletions
This file was deleted.

0 commit comments

Comments
 (0)