Skip to content

Commit 2ec1efc

Browse files
committed
ci: update release pipelines/scripts
1 parent 6f1a1ea commit 2ec1efc

File tree

6 files changed

+45
-92
lines changed

6 files changed

+45
-92
lines changed

.github/workflows/release-prechecks.yml

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -61,16 +61,9 @@ jobs:
6161
cargo install typos-cli --force
6262
fi
6363
64-
- name: Import GPG key
65-
uses: crazy-max/ghaction-import-gpg@v6
66-
with:
67-
gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }}
68-
6964
- name: Run GoReleaser test
7065
env:
7166
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
7267
RELEASE_TOKEN: ${{ secrets.RELEASE_TOKEN }}
73-
GPG_PRIVATE_KEY: ${{ secrets.GPG_PRIVATE_KEY }}
74-
GPG_FINGERPRINT: ${{ secrets.GPG_FINGERPRINT }}
7568
run: |
7669
make goreleaser-test

.github/workflows/release.yml

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -58,11 +58,6 @@ jobs:
5858
cargo install typos-cli --force
5959
fi
6060
61-
- name: Import GPG key
62-
uses: crazy-max/ghaction-import-gpg@v6
63-
with:
64-
gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }}
65-
6661
- name: Run GoReleaser
6762
uses: goreleaser/goreleaser-action@v6
6863
with:
@@ -72,7 +67,6 @@ jobs:
7267
env:
7368
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
7469
RELEASE_TOKEN: ${{ secrets.RELEASE_TOKEN }}
75-
GPG_FINGERPRINT: ${{ secrets.GPG_FINGERPRINT }}
7670

7771
- name: Update GitHub Release with Release Notes
7872
env:

.goreleaser.yml

Lines changed: 4 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,11 @@ before:
1212

1313
builds:
1414
- main: ./main.go
15-
binary: spc
15+
binary: spc.exe
1616
env:
1717
- CGO_ENABLED=0
18+
goos:
19+
- windows
1820
goarch:
1921
- amd64
2022
flags:
@@ -36,24 +38,6 @@ archives:
3638
- goos: windows
3739
formats: [zip]
3840

39-
signs:
40-
- artifacts: checksum
41-
args:
42-
[
43-
"--pinentry-mode",
44-
"loopback",
45-
"--batch",
46-
"-u",
47-
"{{ .Env.GPG_FINGERPRINT }}",
48-
"--output",
49-
"${signature}",
50-
"--detach-sign",
51-
"${artifact}",
52-
]
53-
54-
source:
55-
enabled: true
56-
5741
checksum:
5842
name_template: checksums.txt
5943

@@ -76,7 +60,7 @@ scoops:
7660
- name: spc
7761
repository:
7862
owner: Norgate-AV
79-
name: scoop-bucket-crestron
63+
name: scoop-norgateav-crestron
8064
token: "{{ .Env.RELEASE_TOKEN }}"
8165
directory: bucket
8266
homepage: https://github.com/Norgate-AV/spc

Makefile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,9 @@ deps:
9999

100100
ci: deps lint test build
101101

102+
goreleaser-test:
103+
@./scripts/test-goreleaser.sh
104+
102105
# Show help
103106
help:
104107
@echo "Available targets:"
@@ -114,5 +117,6 @@ help:
114117
@echo " lint - Run fmt, vet, and golangci-lint"
115118
@echo " deps - Download dependencies"
116119
@echo " ci - Run CI pipeline (deps, lint, test, build)"
120+
@echo " goreleaser-test - Test GoReleaser configuration (snapshot build)"
117121
@echo " all - Clean, test, and build"
118122
@echo " help - Show this help"

scripts/commit-changelog.sh

Lines changed: 34 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,20 +12,47 @@ if [[ -z "$TAG" ]]; then
1212
exit 1
1313
fi
1414

15+
# Determine the default branch - try multiple methods for CI reliability
16+
if [[ -n "$GITHUB_REF_NAME" ]]; then
17+
# In GitHub Actions, use the base ref or default to master
18+
DEFAULT_BRANCH="${GITHUB_BASE_REF:-master}"
19+
elif git symbolic-ref refs/remotes/origin/HEAD &>/dev/null; then
20+
# If symbolic ref exists, use it
21+
DEFAULT_BRANCH=$(git symbolic-ref refs/remotes/origin/HEAD | sed 's@^refs/remotes/origin/@@')
22+
else
23+
# Fallback to fetching default branch from GitHub API or assume master
24+
DEFAULT_BRANCH=$(git remote show origin | grep 'HEAD branch' | cut -d' ' -f5 || echo "master")
25+
fi
26+
27+
echo "Target branch: $DEFAULT_BRANCH"
28+
1529
# Check if CHANGELOG.md has changes
1630
if [[ -n "$(git status --porcelain CHANGELOG.md)" ]]; then
17-
echo "📝 Committing updated CHANGELOG.md for $TAG"
31+
echo "Committing updated CHANGELOG.md for $TAG"
32+
33+
# Configure git
1834
git config --global user.name "github-actions[bot]"
1935
git config --global user.email "github-actions[bot]@users.noreply.github.com"
36+
37+
# Fetch the latest state of the default branch
38+
git fetch origin "$DEFAULT_BRANCH"
39+
40+
# Checkout the default branch (handles detached HEAD)
41+
git checkout "$DEFAULT_BRANCH"
42+
43+
# Pull latest changes to avoid conflicts
44+
git pull origin "$DEFAULT_BRANCH" --rebase || {
45+
echo "Warning: Could not rebase. Attempting to continue..."
46+
}
47+
48+
# Add and commit the changelog
2049
git add CHANGELOG.md
2150
git commit -m "chore: update CHANGELOG.md for $TAG [skip ci]"
2251

23-
# Determine the default branch from the remote 'origin'
24-
# This is more reliable in CI environments (detached HEAD)
25-
DEFAULT_BRANCH=$(git symbolic-ref refs/remotes/origin/HEAD | sed 's@^refs/remotes/origin/@@')
26-
git push origin HEAD:"$DEFAULT_BRANCH"
52+
# Push to the default branch
53+
git push origin "$DEFAULT_BRANCH"
2754

28-
echo "CHANGELOG.md committed and pushed to $DEFAULT_BRANCH"
55+
echo "CHANGELOG.md committed and pushed to $DEFAULT_BRANCH"
2956
else
30-
echo "ℹ️ No changes to CHANGELOG.md to commit"
57+
echo "No changes to CHANGELOG.md to commit"
3158
fi

scripts/test-goreleaser.sh

Lines changed: 3 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -81,18 +81,6 @@ check_gh_auth() {
8181
fi
8282
}
8383

84-
check_ghcr_auth() {
85-
local token="$1"
86-
local actor="$2"
87-
88-
if echo "${token}" | docker login ghcr.io -u "${actor}" --password-stdin &> /dev/null; then
89-
print_success "Authenticated with GHCR"
90-
else
91-
MISSING_AUTH+=("GHCR")
92-
print_error "Failed to authenticate with GHCR"
93-
fi
94-
}
95-
9684
check_token_contents_permission() {
9785
local token="$1"
9886
local repo="$2"
@@ -135,33 +123,6 @@ check_token_contents_permission() {
135123
fi
136124
}
137125

138-
check_token_pr_permission() {
139-
local token="$1"
140-
local repo="$2"
141-
local token_name="$3"
142-
143-
if [ -z "$token" ]; then
144-
return
145-
fi
146-
147-
local http_status
148-
http_status=$(curl -s -o /dev/null -w "%{http_code}" \
149-
-X POST \
150-
-H "Authorization: token $token" \
151-
-d '{"title":"Test PR","head":"test-branch","base":"master","draft":true}' \
152-
"https://api.github.com/repos/$repo/pulls")
153-
154-
if [ "$http_status" -eq 422 ]; then
155-
print_success "pull_requests:write permission verified for $repo"
156-
elif [ "$http_status" -eq 403 ]; then
157-
print_error "Failed to create draft PR on $repo (HTTP status: $http_status). This indicates a permission issue."
158-
MISSING_PERMISSIONS+=("$token_name (failed to create draft PR on $repo)")
159-
else
160-
print_error "Unexpected error when creating a draft PR on $repo (HTTP status: $http_status)"
161-
MISSING_PERMISSIONS+=("$token_name (unexpected error when creating a draft PR on $repo)")
162-
fi
163-
}
164-
165126
check_goreleaser_env_vars() {
166127
print_status "Checking for referenced environment variables in .goreleaser.yml..."
167128

@@ -200,16 +161,13 @@ echo ""
200161
print_status "2. 📋 Checking Required Secrets..."
201162

202163
check_secret "GITHUB_TOKEN" "GitHub Actions token (auto-provided)"
203-
check_secret "RELEASE_TOKEN" "Token for Homebrew tap repository"
204-
check_secret "GPG_PRIVATE_KEY" "GPG private key for package signing"
205-
check_secret "GPG_FINGERPRINT" "GPG key fingerprint for package signing"
164+
check_secret "RELEASE_TOKEN" "Token for Scoop repository"
206165
echo ""
207166

208167
# 3. Required repositories check
209168
print_status "3. 🏗️ Checking Required Repositories..."
210169

211-
check_github_repo "damienbutt/scoop-bucket" "Scoop bucket repository" "${GITHUB_TOKEN}"
212-
check_github_repo "damienbutt/winget-pkgs" "Winget package repository" "${GITHUB_TOKEN}"
170+
check_github_repo "Norgate-AV/scoop-norgateav-crestron" "Scoop bucket repository" "${GITHUB_TOKEN}"
213171
echo ""
214172

215173
# 4. Check build tools
@@ -218,7 +176,6 @@ print_status "4. 🔧 Checking Build Tools..."
218176
check_tool "go"
219177
check_tool "git"
220178
check_tool "gh"
221-
check_tool "gpg"
222179
check_tool "git-cliff"
223180
check_tool "typos"
224181
check_tool "curl"
@@ -237,23 +194,18 @@ if command -v gh &> /dev/null; then
237194
check_gh_auth
238195
fi
239196

240-
check_ghcr_auth "${GITHUB_TOKEN}" "${GITHUB_ACTOR}"
241-
echo ""
242-
243197
print_status "6. 🔑 Checking Release Token Permissions..."
244198

245199
if [ -z "${RELEASE_TOKEN}" ]; then
246200
print_warning "RELEASE_TOKEN is not set; skipping permission checks"
247201
WARNINGS+=("RELEASE_TOKEN is not set; skipping permission checks")
248202
else
249203
REPOS_TO_CHECK=(
250-
"damienbutt/scoop-bucket"
251-
"damienbutt/winget-pkgs"
204+
"Norgate-AV/scoop-norgateav-crestron"
252205
)
253206

254207
for repo in "${REPOS_TO_CHECK[@]}"; do
255208
check_token_contents_permission "${RELEASE_TOKEN}" "$repo" "RELEASE_TOKEN"
256-
check_token_pr_permission "${RELEASE_TOKEN}" "$repo" "RELEASE_TOKEN"
257209
done
258210
fi
259211
echo ""
@@ -342,7 +294,6 @@ print_success "All required repositories are accessible."
342294
print_success "All required build tools are installed."
343295
print_success "All release token permissions are verified."
344296
print_success "GitHub CLI is authenticated."
345-
print_success "Authenticated with GHCR."
346297

347298
if [ "$GO_RELEASER_SUCCESS" = true ]; then
348299
print_success "GoReleaser release process completed successfully."

0 commit comments

Comments
 (0)