-
Notifications
You must be signed in to change notification settings - Fork 2
126 lines (107 loc) · 3.56 KB
/
Copy pathrelease.yml
File metadata and controls
126 lines (107 loc) · 3.56 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
name: Release
on:
push:
tags:
- "v*"
permissions:
contents: write
packages: write
jobs:
test:
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
runs-on: ${{ matrix.os }}
steps:
- name: Checkout
uses: actions/checkout@v6
with:
fetch-depth: 0
- name: Set up Go
uses: actions/setup-go@v6
with:
go-version-file: go.mod
- name: Run tests
run: go test ./... -v
release:
needs: [test]
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v6
with:
fetch-depth: 0
- name: Set up Go
uses: actions/setup-go@v6
with:
go-version-file: go.mod
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Log in to GHCR
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v6
with:
version: "~> v2"
args: release --clean
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
dispatch-docsite:
needs: [release]
runs-on: ubuntu-latest
steps:
- name: Mint app token for api-specs
id: app-token
uses: actions/create-github-app-token@v3
with:
client-id: ${{ secrets.APP_CLIENT_ID }}
private-key: ${{ secrets.APP_PRIVATE_KEY }}
owner: Bandwidth
repositories: api-specs
- name: Trigger docsite CLI reference update
env:
GH_TOKEN: ${{ steps.app-token.outputs.token }}
run: |
gh api repos/Bandwidth/api-specs/dispatches \
-f event_type=cli-docs-update \
-F client_payload[version]="${{ github.ref_name }}"
bump-formula:
needs: [release]
runs-on: ubuntu-latest
steps:
- name: Bump Homebrew formula
env:
GH_TOKEN: ${{ secrets.HOMEBREW_TAP_TOKEN }}
VERSION: ${{ github.ref_name }}
run: |
set -euo pipefail
TAP="Bandwidth/homebrew-tap"
FORMULA="Formula/band.rb"
URL="https://github.com/Bandwidth/cli/archive/refs/tags/${VERSION}.tar.gz"
# Checksum the exact archive brew downloads: curl follows GitHub's redirect
# to codeload, so this sha256 always matches the formula url's payload.
SHA="$(curl -fsSL "$URL" | sha256sum | cut -d' ' -f1)"
git clone "https://x-access-token:${GH_TOKEN}@github.com/${TAP}.git" tap
cd tap
sed -i -E "s|^(\s*url ).*|\1\"${URL}\"|" "$FORMULA"
sed -i -E "s|^(\s*sha256 ).*|\1\"${SHA}\"|" "$FORMULA"
if git diff --quiet; then
echo "Formula already at ${VERSION}; nothing to bump."
exit 0
fi
BRANCH="bump-band-${VERSION}"
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
git switch -C "$BRANCH"
git commit -am "band ${VERSION}"
git push -f origin "$BRANCH"
# Re-run safe: only open a PR if one isn't already open for this branch.
if [ -z "$(gh pr list --repo "$TAP" --head "$BRANCH" --state open --json number --jq '.[0].number')" ]; then
gh pr create --repo "$TAP" --base main --head "$BRANCH" \
--title "band ${VERSION}" \
--body "Automated formula bump to ${VERSION}."
fi