Skip to content

Commit 2d3b078

Browse files
committed
ci: harden nightly cask publish workflow
1 parent b7b1ab2 commit 2d3b078

1 file changed

Lines changed: 23 additions & 19 deletions

File tree

.github/workflows/nightly-cask.yml

Lines changed: 23 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ on:
66
- main
77
workflow_dispatch:
88

9+
concurrency:
10+
group: nightly-cask
11+
cancel-in-progress: true
12+
913
permissions:
1014
contents: write
1115

@@ -70,18 +74,19 @@ jobs:
7074
7175
gh release upload nightly /tmp/nightly-dist/*.tar.gz
7276
73-
- name: Clone tap repository
74-
env:
75-
HOMEBREW_TAP_TOKEN: ${{ secrets.HOMEBREW_TAP_TOKEN }}
76-
run: |
77-
set -euo pipefail
78-
git clone "https://x-access-token:${HOMEBREW_TAP_TOKEN}@github.com/sensiblebit/homebrew-tap.git" /tmp/homebrew-tap
77+
- name: Checkout tap repository
78+
uses: actions/checkout@v6
79+
with:
80+
repository: sensiblebit/homebrew-tap
81+
path: homebrew-tap
82+
fetch-depth: 0
83+
token: ${{ secrets.HOMEBREW_TAP_TOKEN }}
7984

8085
- name: Render nightly cask
8186
run: |
8287
set -euo pipefail
83-
mkdir -p /tmp/homebrew-tap/Casks
84-
cat > /tmp/homebrew-tap/Casks/certkit@nightly.rb <<EOF
88+
mkdir -p homebrew-tap/Casks
89+
cat > homebrew-tap/Casks/certkit@nightly.rb <<EOF
8590
# This file is auto-generated by certkit nightly workflow. DO NOT EDIT.
8691
cask "certkit@nightly" do
8792
name "certkit nightly"
@@ -94,6 +99,12 @@ cask "certkit@nightly" do
9499
end
95100

96101
conflicts_with cask: "certkit"
102+
103+
postflight do
104+
system_command "/usr/bin/xattr",
105+
args: ["-dr", "com.apple.quarantine", "#{staged_path}"]
106+
end
107+
97108
binary "certkit"
98109

99110
on_macos do
@@ -120,7 +131,7 @@ cask "certkit@nightly" do
120131
end
121132
EOF
122133

123-
stable_cask="/tmp/homebrew-tap/Casks/certkit.rb"
134+
stable_cask="homebrew-tap/Casks/certkit.rb"
124135
if [[ -f "${stable_cask}" ]] && ! grep -q 'conflicts_with cask: "certkit@nightly"' "${stable_cask}"; then
125136
awk '
126137
/^[[:space:]]*binary "certkit"/ && !inserted {
@@ -140,17 +151,10 @@ EOF
140151
- name: Commit and push tap update
141152
run: |
142153
set -euo pipefail
143-
cd /tmp/homebrew-tap
144-
145-
changed=0
146-
if ! git diff --quiet -- Casks/certkit@nightly.rb; then
147-
changed=1
148-
fi
149-
if [[ -f Casks/certkit.rb ]] && ! git diff --quiet -- Casks/certkit.rb; then
150-
changed=1
151-
fi
154+
cd homebrew-tap
152155
153-
if [[ "${changed}" -eq 0 ]]; then
156+
changed_files="$(git status --porcelain -- Casks/certkit@nightly.rb Casks/certkit.rb || true)"
157+
if [[ -z "${changed_files}" ]]; then
154158
echo "No cask changes detected."
155159
exit 0
156160
fi

0 commit comments

Comments
 (0)