Skip to content

Commit 3cf83db

Browse files
committed
ci: publish versioned github-workflows releases
Signed-off-by: Vitor Mattos <vitor@php.rio>
1 parent 59fdef7 commit 3cf83db

1 file changed

Lines changed: 67 additions & 0 deletions

File tree

‎.github/workflows/release.yml‎

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
# SPDX-FileCopyrightText: 2026 LibreCode coop and contributors
2+
# SPDX-License-Identifier: AGPL-3.0-or-later
3+
4+
name: Release
5+
6+
on:
7+
push:
8+
branches:
9+
- main
10+
paths:
11+
- VERSION
12+
workflow_dispatch:
13+
14+
permissions:
15+
contents: write
16+
17+
concurrency:
18+
group: release
19+
cancel-in-progress: false
20+
21+
jobs:
22+
release:
23+
name: Publish versioned release
24+
if: github.ref == 'refs/heads/main'
25+
runs-on: ubuntu-latest
26+
timeout-minutes: 15
27+
28+
steps:
29+
- name: Checkout
30+
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
31+
with:
32+
fetch-depth: 0
33+
persist-credentials: false
34+
35+
- name: Read and validate version
36+
id: version
37+
shell: bash
38+
run: |
39+
set -euo pipefail
40+
version="$(tr -d '[:space:]' < VERSION)"
41+
if ! [[ "$version" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
42+
echo "VERSION must use MAJOR.MINOR.PATCH" >&2
43+
exit 1
44+
fi
45+
echo "version=$version" >> "$GITHUB_OUTPUT"
46+
echo "tag=v$version" >> "$GITHUB_OUTPUT"
47+
48+
- name: Run project checks
49+
run: |
50+
python3 -m unittest discover -s tests -p 'test_*.py'
51+
python3 scripts/sync_upstream.py check upstream/sources.json
52+
python3 scripts/render_upstream.py check upstream/templates.json
53+
python3 scripts/check_workflow_policy.py
54+
55+
- name: Publish GitHub release
56+
env:
57+
GH_TOKEN: ${{ github.token }}
58+
TAG: ${{ steps.version.outputs.tag }}
59+
shell: bash
60+
run: |
61+
set -euo pipefail
62+
if gh release view "$TAG" --repo "$GITHUB_REPOSITORY" >/dev/null 2>&1; then
63+
echo "Release $TAG already exists; nothing to do."
64+
exit 0
65+
fi
66+
67+
gh release create "$TAG" --repo "$GITHUB_REPOSITORY" --target "$GITHUB_SHA" --title "$TAG" --generate-notes

0 commit comments

Comments
 (0)