Skip to content

Commit d710a6c

Browse files
committed
Merge branch 'main' of https://github.com/hookdeck/hookdeck-cli into fix/project-use-default
2 parents afafbaf + 6994c51 commit d710a6c

40 files changed

+1461
-513
lines changed
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
name: Acceptance Tests
2+
3+
on:
4+
pull_request:
5+
branches:
6+
- main
7+
8+
jobs:
9+
test:
10+
runs-on: ubuntu-latest
11+
env:
12+
HOOKDECK_CLI_TESTING_API_KEY: ${{ secrets.HOOKDECK_CLI_TESTING_API_KEY }}
13+
steps:
14+
- name: Check out code
15+
uses: actions/checkout@v3
16+
17+
- name: Set up Go
18+
uses: actions/setup-go@v3
19+
with:
20+
go-version: '1.18'
21+
22+
- name: Make script executable
23+
run: chmod +x scripts/acceptance-test.sh
24+
25+
- name: Run acceptance tests
26+
run: ./scripts/acceptance-test.sh

.github/workflows/release.yml

Lines changed: 40 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@ jobs:
1818
with:
1919
go-version: 1.18.1
2020
- name: Run GoReleaser
21-
uses: goreleaser/goreleaser-action@v4
21+
uses: goreleaser/goreleaser-action@v5
2222
with:
23-
version: latest
23+
version: v2.10.2
2424
args: release -f .goreleaser/mac.yml --clean
2525
env:
2626
GITHUB_TOKEN: ${{ secrets.GORELEASER_GITHUB_TOKEN }}
@@ -49,9 +49,9 @@ jobs:
4949
with:
5050
go-version: 1.18.1
5151
- name: Run GoReleaser
52-
uses: goreleaser/goreleaser-action@v4
52+
uses: goreleaser/goreleaser-action@v5
5353
with:
54-
version: latest
54+
version: v2.10.2
5555
args: release -f .goreleaser/linux.yml --clean
5656
env:
5757
GITHUB_TOKEN: ${{ secrets.GORELEASER_GITHUB_TOKEN }}
@@ -70,41 +70,40 @@ jobs:
7070
- name: Run GoReleaser
7171
uses: goreleaser/goreleaser-action@v5
7272
with:
73-
version: latest
73+
version: v2.10.2
7474
args: release -f .goreleaser/windows.yml --clean
7575
env:
7676
GITHUB_TOKEN: ${{ secrets.GORELEASER_GITHUB_TOKEN }}
7777

78-
build-windows-npm:
79-
runs-on: windows-latest
80-
steps:
81-
- name: Code checkout
82-
uses: actions/checkout@v4
83-
with:
84-
fetch-depth: 0
85-
- name: Set up Go
86-
uses: actions/setup-go@v5
87-
with:
88-
go-version: 1.18.1
89-
- name: Run GoReleaser
90-
uses: goreleaser/goreleaser-action@v5
91-
with:
92-
version: latest
93-
args: release -f .goreleaser/windows-npm.yml --clean
94-
env:
95-
GITHUB_TOKEN: ${{ secrets.GORELEASER_GITHUB_TOKEN }}
96-
9778
publish-npm:
9879
runs-on: ubuntu-latest
99-
needs: [build-windows-npm, build-linux, build-mac]
80+
needs: [build-windows, build-linux, build-mac]
10081
steps:
10182
- uses: actions/checkout@v4
10283
with:
103-
# Checkout on main so that the later commit works
104-
ref: main
10584
# With permission to push to a protected branch
10685
token: ${{ secrets.READ_WRITE_PAT }}
107-
86+
fetch-depth: 0 # Required to find branches for a tag
87+
88+
- name: Determine release branch
89+
id: get_branch
90+
run: |
91+
# Find the branch that contains the tag.
92+
# Prefers 'main', then 'master', then the first branch found.
93+
BRANCHES=$(git branch -r --contains ${{ github.ref_name }} | sed 's/ *origin\///' | grep -v HEAD)
94+
if echo "$BRANCHES" | grep -q -w "main"; then
95+
RELEASE_BRANCH="main"
96+
elif echo "$BRANCHES" | grep -q -w "master"; then
97+
RELEASE_BRANCH="master"
98+
else
99+
RELEASE_BRANCH=$(echo "$BRANCHES" | head -n 1)
100+
fi
101+
echo "RELEASE_BRANCH=${RELEASE_BRANCH}" >> $GITHUB_OUTPUT
102+
echo "Determined release branch for commit: ${RELEASE_BRANCH}"
103+
104+
- name: Checkout release branch
105+
run: git checkout ${{ steps.get_branch.outputs.RELEASE_BRANCH }}
106+
108107
- uses: actions/setup-node@v4
109108
with:
110109
node-version: "20.x"
@@ -133,6 +132,18 @@ jobs:
133132
add: 'package.json'
134133

135134
- run: npm ci
136-
- run: npm publish
135+
136+
- name: Determine npm tag for pre-releases
137+
id: npm_tag
138+
run: |
139+
TAG_VERSION="${{ steps.tag-version.outputs.TAG_VERSION }}"
140+
NPM_TAG="latest"
141+
if [[ "$TAG_VERSION" == *-* ]]; then
142+
NPM_TAG=$(echo "$TAG_VERSION" | cut -d'-' -f2 | cut -d'.' -f1)
143+
fi
144+
echo "tag=${NPM_TAG}" >> $GITHUB_OUTPUT
145+
echo "npm tag: ${NPM_TAG}"
146+
147+
- run: npm publish --tag ${{ steps.npm_tag.outputs.tag }}
137148
env:
138149
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

.github/workflows/test.yml

Lines changed: 5 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,9 @@ jobs:
2323
with:
2424
go-version: 1.18.1
2525
- name: Run GoReleaser
26-
uses: goreleaser/goreleaser-action@v4
26+
uses: goreleaser/goreleaser-action@v5
2727
with:
28-
version: latest
28+
version: v2.10.2
2929
args: release --skip=publish --snapshot -f .goreleaser/mac.yml --clean
3030
env:
3131
GITHUB_TOKEN: ${{ secrets.GORELEASER_GITHUB_TOKEN }}
@@ -55,9 +55,9 @@ jobs:
5555
with:
5656
go-version: 1.18.1
5757
- name: Run GoReleaser
58-
uses: goreleaser/goreleaser-action@v4
58+
uses: goreleaser/goreleaser-action@v5
5959
with:
60-
version: latest
60+
version: v2.10.2
6161
args: release --skip=publish --snapshot -f .goreleaser/linux.yml --clean
6262
env:
6363
GITHUB_TOKEN: ${{ secrets.GORELEASER_GITHUB_TOKEN }}
@@ -76,26 +76,7 @@ jobs:
7676
- name: Run GoReleaser
7777
uses: goreleaser/goreleaser-action@v5
7878
with:
79-
version: latest
79+
version: v2.10.2
8080
args: release --skip=publish --snapshot -f .goreleaser/windows.yml --clean
8181
env:
8282
GITHUB_TOKEN: ${{ secrets.GORELEASER_GITHUB_TOKEN }}
83-
84-
build-windows-npm:
85-
runs-on: windows-latest
86-
steps:
87-
- name: Code checkout
88-
uses: actions/checkout@v4
89-
with:
90-
fetch-depth: 0
91-
- name: Set up Go
92-
uses: actions/setup-go@v5
93-
with:
94-
go-version: 1.18.1
95-
- name: Run GoReleaser
96-
uses: goreleaser/goreleaser-action@v5
97-
with:
98-
version: latest
99-
args: release --skip=publish --snapshot -f .goreleaser/windows-npm.yml --clean
100-
env:
101-
GITHUB_TOKEN: ${{ secrets.GORELEASER_GITHUB_TOKEN }}

.goreleaser/linux.yml

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
version: 2
12
env:
23
- GO111MODULE=on
34
before:
@@ -55,8 +56,8 @@ dockers:
5556
ids:
5657
- hookdeck-linux
5758
image_templates:
58-
- "hookdeck/hookdeck-cli:latest-amd64"
5959
- "hookdeck/hookdeck-cli:{{ .Tag }}-amd64"
60+
- "{{ if not .Prerelease }}hookdeck/hookdeck-cli:latest-amd64{{ end }}"
6061
build_flag_templates:
6162
- "--pull"
6263
- "--label=org.opencontainers.image.created={{.Date}}"
@@ -71,8 +72,8 @@ dockers:
7172
ids:
7273
- hookdeck-linux-arm64
7374
image_templates:
74-
- "hookdeck/hookdeck-cli:latest-arm64"
7575
- "hookdeck/hookdeck-cli:{{ .Tag }}-arm64"
76+
- "{{ if not .Prerelease }}hookdeck/hookdeck-cli:latest-arm64{{ end }}"
7677
build_flag_templates:
7778
- "--pull"
7879
- "--label=org.opencontainers.image.created={{.Date}}"
@@ -83,11 +84,12 @@ dockers:
8384
- "--label=homepage=https://hookdeck.com"
8485
- "--platform=linux/arm64/v8"
8586
docker_manifests:
86-
- name_template: "hookdeck/hookdeck-cli:latest"
87-
image_templates:
88-
- "hookdeck/hookdeck-cli:latest-amd64"
89-
- "hookdeck/hookdeck-cli:latest-arm64"
9087
- name_template: "hookdeck/hookdeck-cli:{{ .Tag }}"
9188
image_templates:
9289
- "hookdeck/hookdeck-cli:{{ .Tag }}-amd64"
9390
- "hookdeck/hookdeck-cli:{{ .Tag }}-arm64"
91+
- name_template: "hookdeck/hookdeck-cli:latest"
92+
image_templates:
93+
- "hookdeck/hookdeck-cli:latest-amd64"
94+
- "hookdeck/hookdeck-cli:latest-arm64"
95+
skip_push: auto

.goreleaser/mac.yml

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
version: 2
12
env:
23
- GO111MODULE=on
34
before:
@@ -36,28 +37,29 @@ checksum:
3637
name_template: "{{ .ProjectName }}-checksums.txt"
3738
snapshot:
3839
name_template: "{{ .Tag }}-next"
39-
brews:
40-
- repository:
40+
homebrew_casks:
41+
- name: hookdeck
42+
repository:
4143
owner: hookdeck
4244
name: homebrew-hookdeck
4345
commit_author:
4446
name: hookdeck
4547
4648
homepage: https://hookdeck.com
4749
description: Hookdeck CLI utility
48-
install: |
49-
bin.install "hookdeck"
50-
rm Dir["#{bin}/{hookdeck-completion.bash,hookdeck-completion.zsh}"]
51-
system bin/"hookdeck", "completion", "--shell", "bash"
52-
system bin/"hookdeck", "completion", "--shell", "zsh"
53-
bash_completion.install "hookdeck-completion.bash"
54-
zsh_completion.install "hookdeck-completion.zsh"
55-
(zsh_completion/"_hookdeck").write <<~EOS
56-
#compdef hookdeck
57-
_hookdeck () {
58-
local e
59-
e=$(dirname ${funcsourcetrace[1]%:*})/hookdeck-completion.zsh
60-
if [[ -f $e ]]; then source $e; fi
61-
}
62-
EOS
6350
caveats: "❤ Thanks for installing the Hookdeck CLI! If this is your first time using the CLI, be sure to run `hookdeck login` first."
51+
custom_block: |
52+
postflight do
53+
system "hookdeck", "completion", "--shell", "bash"
54+
system "hookdeck", "completion", "--shell", "zsh"
55+
bash_completion.install "hookdeck-completion.bash"
56+
zsh_completion.install "hookdeck-completion.zsh"
57+
(zsh_completion/"_hookdeck").write <<~EOS
58+
#compdef hookdeck
59+
_hookdeck () {
60+
local e
61+
e=$(dirname ${funcsourcetrace[1]%:*})/hookdeck-completion.zsh
62+
if [[ -f $e ]]; then source $e; fi
63+
}
64+
EOS
65+
end

.goreleaser/windows-npm.yml

Lines changed: 0 additions & 45 deletions
This file was deleted.

.goreleaser/windows.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
version: 2
12
env:
23
- GO111MODULE=on
34
before:
@@ -40,6 +41,7 @@ scoops:
4041
- repository:
4142
owner: hookdeck
4243
name: scoop-hookdeck
44+
name: "{{ if .Prerelease }}hookdeck-beta{{ else }}hookdeck{{ end }}"
4345
commit_author:
4446
name: hookdeck-ci
4547

0 commit comments

Comments
 (0)