-
Notifications
You must be signed in to change notification settings - Fork 3
111 lines (100 loc) · 3.52 KB
/
Copy pathrelease.yml
File metadata and controls
111 lines (100 loc) · 3.52 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
name: Release
on:
push:
tags: ["v*"]
permissions:
contents: write
jobs:
build:
strategy:
matrix:
include:
- os: macos-latest
target: aarch64-apple-darwin
bottle_tag: arm64_sequoia
- os: ubuntu-latest
target: x86_64-unknown-linux-gnu
bottle_tag: x86_64_linux
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.target }}
- run: cargo build --release --target ${{ matrix.target }}
- name: Package bottle
run: |
VERSION=${GITHUB_REF_NAME#v}
mkdir -p "jj-hunk/${VERSION}/bin"
cp "target/${{ matrix.target }}/release/jj-hunk" "jj-hunk/${VERSION}/bin/"
tar czf "jj-hunk-${VERSION}.${{ matrix.bottle_tag }}.bottle.tar.gz" "jj-hunk/${VERSION}/"
- uses: actions/upload-artifact@v4
with:
name: bottle-${{ matrix.bottle_tag }}
path: "*.bottle.tar.gz"
release:
needs: build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/download-artifact@v4
with:
merge-multiple: true
- name: Generate changelog
uses: orhun/git-cliff-action@v4
id: changelog
with:
args: --latest --strip header
env:
OUTPUT: CHANGELOG.md
- name: Create release
uses: softprops/action-gh-release@v2
with:
body_path: CHANGELOG.md
files: "*.bottle.tar.gz"
update-tap:
needs: release
runs-on: ubuntu-latest
steps:
- uses: actions/download-artifact@v4
with:
merge-multiple: true
- name: Update homebrew formula
env:
GH_TOKEN: ${{ secrets.TAP_GITHUB_TOKEN }}
run: |
VERSION=${GITHUB_REF_NAME#v}
SOURCE_SHA=$(curl -sL "https://github.com/laulauland/jj-hunk/archive/refs/tags/v${VERSION}.tar.gz" | shasum -a 256 | cut -d' ' -f1)
ARM64_SHA=$(shasum -a 256 "jj-hunk-${VERSION}.arm64_sequoia.bottle.tar.gz" | cut -d' ' -f1)
LINUX_SHA=$(shasum -a 256 "jj-hunk-${VERSION}.x86_64_linux.bottle.tar.gz" | cut -d' ' -f1)
cat > /tmp/jj-hunk.rb << RUBY
class JjHunk < Formula
desc "Programmatic hunk selection for jj"
homepage "https://github.com/laulauland/jj-hunk"
url "https://github.com/laulauland/jj-hunk/archive/refs/tags/v${VERSION}.tar.gz"
sha256 "${SOURCE_SHA}"
license "MIT"
bottle do
root_url "https://github.com/laulauland/jj-hunk/releases/download/v${VERSION}"
sha256 arm64_sequoia: "${ARM64_SHA}"
sha256 x86_64_linux: "${LINUX_SHA}"
end
depends_on "rust" => :build
def install
system "cargo", "install", *std_cargo_args
end
test do
assert_match "jj-hunk", shell_output("#{bin}/jj-hunk --help")
end
end
RUBY
# Remove leading whitespace from heredoc
sed -i 's/^ //' /tmp/jj-hunk.rb
EXISTING_SHA=$(gh api repos/laulauland/homebrew-tap/contents/Formula/jj-hunk.rb --jq '.sha')
gh api repos/laulauland/homebrew-tap/contents/Formula/jj-hunk.rb \
--method PUT \
--field message="jj-hunk ${VERSION}" \
--field content="$(base64 -w0 /tmp/jj-hunk.rb)" \
--field sha="${EXISTING_SHA}"