WARNING: THIS SITE IS A MIRROR OF GITHUB.COM / IT CANNOT LOGIN OR REGISTER ACCOUNTS / THE CONTENTS ARE PROVIDED AS-IS / THIS SITE ASSUMES NO RESPONSIBILITY FOR ANY DISPLAYED CONTENT OR LINKS / IF YOU FOUND SOMETHING MAY NOT GOOD FOR EVERYONE, CONTACT ADMIN AT ilovescratch@foxmail.com
Skip to content

Commit 0eb1254

Browse files
authored
Fix GitHub Actions workflow for releases
Removed tagging job and updated release process to create and push tags based on PKGBUILD parsing.
1 parent 19576ae commit 0eb1254

File tree

1 file changed

+38
-39
lines changed

1 file changed

+38
-39
lines changed

.github/workflows/build.yml

Lines changed: 38 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@ on:
44
push:
55
branches:
66
- main
7-
tags:
8-
- 'v*'
97
paths:
108
- PKGBUILD
119
- .github/workflows/**
@@ -15,40 +13,6 @@ permissions:
1513
packages: write
1614

1715
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 )
35-
PKGREL=$(sed -n 's/^pkgrel=//p' PKGBUILD | head -n1 )
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-
5216
build:
5317
name: Build package (${{ matrix.pkg_arch }})
5418
runs-on: ubuntu-24.04-arm
@@ -90,29 +54,64 @@ jobs:
9054
path: "*.pkg.tar.*"
9155

9256
release:
93-
name: Publish release
57+
name: Tag and Publish Release
9458
needs: build
9559
runs-on: ubuntu-latest
96-
if: startsWith(github.ref, 'refs/tags/')
9760
permissions:
9861
contents: write
9962
steps:
63+
- name: Checkout
64+
uses: actions/checkout@v4
65+
with:
66+
fetch-depth: 0
67+
68+
- name: Parse tag from PKGBUILD
69+
id: pkg_tag
70+
run: |
71+
PKGVER=$(sed -n 's/^pkgver=//p' PKGBUILD | head -n1 )
72+
PKGREL=$(sed -n 's/^pkgrel=//p' PKGBUILD | head -n1 )
73+
if [ -z "${PKGVER}" ] || [ -z "${PKGREL}" ]; then
74+
echo "Failed to parse pkgver/pkgrel from PKGBUILD" >&2
75+
exit 1
76+
fi
77+
TAG="v${PKGVER}-${PKGREL}"
78+
echo "tag=${TAG}" >> $GITHUB_OUTPUT
79+
80+
- name: Check if tag exists and create/push if needed (and quit if exists)
81+
id: tagcheck
82+
env:
83+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
84+
TAG: ${{ steps.pkg_tag.outputs.tag }}
85+
run: |
86+
set -euo pipefail
87+
if git ls-remote --tags origin | awk '{print $2}' | grep -qx "refs/tags/${TAG}"; then
88+
echo "Tag ${TAG} already exists on remote. Quitting."
89+
exit 0
90+
fi
91+
git config user.name "${GITHUB_ACTOR}"
92+
git config user.email "${GITHUB_ACTOR}@users.noreply.github.com"
93+
git tag -a "${TAG}" -m "Release ${TAG}"
94+
git push origin "refs/tags/${TAG}"
95+
10096
- name: Download built packages
97+
if: steps.tagcheck.outcome == 'success'
10198
uses: actions/download-artifact@v4
10299
with:
103100
pattern: rpicam-apps-*
104101
merge-multiple: true
105102
path: dist
106103

107104
- name: List downloaded files
105+
if: steps.tagcheck.outcome == 'success'
108106
run: ls -lah dist
109107

110108
- name: Create/Update GitHub Release (gh CLI)
109+
if: steps.tagcheck.outcome == 'success'
111110
env:
112111
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
112+
TAG: ${{ steps.pkg_tag.outputs.tag }}
113113
run: |
114114
set -euo pipefail
115-
TAG="${GITHUB_REF_NAME}"
116115
# Create the release if it doesn't exist, otherwise continue
117116
gh release view "$TAG" >/dev/null 2>&1 || gh release create "$TAG" --title "$TAG" --generate-notes
118117
# Upload all pkg artifacts as raw files (no additional zipping)

0 commit comments

Comments
 (0)