Skip to content

Commit e719e50

Browse files
committed
Add release job
1 parent 95a8b01 commit e719e50

1 file changed

Lines changed: 65 additions & 0 deletions

File tree

.github/workflows/build.yml

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ on:
44
push:
55
branches:
66
- main
7+
tags:
8+
- 'v*'
79
paths:
810
- PKGBUILD
911
- .github/workflows/**
@@ -13,6 +15,40 @@ permissions:
1315
packages: write
1416

1517
jobs:
18+
tag_from_pkgbuild:
19+
name: Tag from PKGBUILD
20+
runs-on: ubuntu-latest
21+
if: github.ref == 'refs/heads/main'
22+
permissions:
23+
contents: write
24+
steps:
25+
- name: Checkout
26+
uses: actions/checkout@v4
27+
with:
28+
fetch-depth: 0
29+
- name: Create and push tag from PKGBUILD
30+
env:
31+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
32+
run: |
33+
set -euo pipefail
34+
PKGVER=$(sed -n 's/^pkgver=//p' PKGBUILD | head -n1 | tr -d '"'\'' )
35+
PKGREL=$(sed -n 's/^pkgrel=//p' PKGBUILD | head -n1 | tr -d '"'\'' )
36+
if [ -z "${PKGVER}" ] || [ -z "${PKGREL}" ]; then
37+
echo "Failed to parse pkgver/pkgrel from PKGBUILD" >&2
38+
exit 1
39+
fi
40+
TAG="v${PKGVER}-${PKGREL}"
41+
echo "Computed tag: ${TAG}"
42+
if git ls-remote --tags origin | awk '{print $2}' | grep -qx "refs/tags/${TAG}"; then
43+
echo "Tag ${TAG} already exists on remote. Skipping."
44+
exit 0
45+
fi
46+
git config user.name "${GITHUB_ACTOR}"
47+
git config user.email "${GITHUB_ACTOR}@users.noreply.github.com"
48+
git tag -a "${TAG}" -m "Release ${TAG}"
49+
# Push using the already-configured credentials from checkout
50+
git push origin "refs/tags/${TAG}"
51+
1652
build:
1753
name: Build package (${{ matrix.pkg_arch }})
1854
runs-on: ubuntu-24.04-arm
@@ -52,3 +88,32 @@ jobs:
5288
with:
5389
name: rpicam-apps-${{ matrix.pkg_arch }}
5490
path: "*.pkg.tar.*"
91+
92+
release:
93+
name: Publish release
94+
needs: build
95+
runs-on: ubuntu-latest
96+
if: startsWith(github.ref, 'refs/tags/')
97+
permissions:
98+
contents: write
99+
steps:
100+
- name: Download built packages
101+
uses: actions/download-artifact@v4
102+
with:
103+
pattern: rpicam-apps-*
104+
merge-multiple: true
105+
path: dist
106+
107+
- name: List downloaded files
108+
run: ls -lah dist
109+
110+
- name: Create/Update GitHub Release (gh CLI)
111+
env:
112+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
113+
run: |
114+
set -euo pipefail
115+
TAG="${GITHUB_REF_NAME}"
116+
# Create the release if it doesn't exist, otherwise continue
117+
gh release view "$TAG" >/dev/null 2>&1 || gh release create "$TAG" --title "$TAG" --generate-notes
118+
# Upload all pkg artifacts as raw files (no additional zipping)
119+
gh release upload "$TAG" dist/*.pkg.tar.* --clobber

0 commit comments

Comments
 (0)