-
Notifications
You must be signed in to change notification settings - Fork 2
166 lines (158 loc) · 6.22 KB
/
Copy pathrelease.yml
File metadata and controls
166 lines (158 loc) · 6.22 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
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
name: Release
on:
push:
tags:
- "[0-9]+.*"
pull_request:
workflow_dispatch:
permissions:
contents: read
concurrency:
group: release-${{ github.ref }}
cancel-in-progress: false
jobs:
build:
strategy:
fail-fast: false
matrix:
include:
- target: aarch64-apple-darwin
os: macos-14
- target: x86_64-apple-darwin
os: macos-15-intel
- target: x86_64-unknown-linux-gnu
os: ubuntu-22.04
- target: aarch64-unknown-linux-gnu
os: ubuntu-22.04-arm
runs-on: ${{ matrix.os }}
timeout-minutes: 45
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- uses: oven-sh/setup-bun@0c5077e51419868618aeaa5fe8019c62421857d6 # v2.2.0
with:
bun-version: 1.3.10
- uses: dtolnay/rust-toolchain@stable
- name: Build and package
env:
TARGET: ${{ matrix.target }}
RELEASE_TAG: ${{ github.ref_type == 'tag' && github.ref_name || '' }}
run: |
version=$(cargo metadata --no-deps --format-version 1 | jq -r '.packages[] | select(.name == "diffr-cli") | .version')
if [ -n "$RELEASE_TAG" ] && [ "$RELEASE_TAG" != "$version" ]; then
echo "Tag $RELEASE_TAG does not match Cargo version $version" >&2
exit 1
fi
cargo xtask install --root "$RUNNER_TEMP/install"
cargo install --path . --locked --features all-languages --root "$RUNNER_TEMP/full"
python3 scripts/release.py pack --version "$version" --target "$TARGET" --install "$RUNNER_TEMP/install" --output dist
python3 scripts/release.py pack --version "$version" --target "$TARGET" --install "$RUNNER_TEMP/full" --edition full --output dist
- name: Verify extracted archives without Bun or checkout assets
env:
TARGET: ${{ matrix.target }}
run: |
version=$(sed -n 's/^version = "\([^"]*\)"/\1/p' Cargo.toml | head -1)
mkdir -p "$RUNNER_TEMP/extracted/bin"
tar -xzf "dist/diffr-$version-$TARGET.tar.gz" -C "$RUNNER_TEMP/extracted/bin"
python3 xtask/tests/smoke_install.py "$RUNNER_TEMP/extracted"
python3 scripts/smoke_cli_archive.py "dist/diffr-cli-$version-$TARGET.tar.gz" "$version"
python3 scripts/smoke_cli_archive.py "dist/diffr-cli-full-$version-$TARGET.tar.gz" "$version"
- uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
with:
name: ${{ matrix.target }}
path: dist/*.tar.gz
if-no-files-found: error
prepare:
needs: build
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0
with:
path: dist
merge-multiple: true
- name: Generate checksums and Homebrew formula
run: |
version=$(sed -n 's/^version = "\([^"]*\)"/\1/p' Cargo.toml | head -1)
python3 scripts/release.py formula --version "$version" --output dist
(cd dist && sha256sum --check SHA256SUMS)
ruby -c dist/diffr.rb
- uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
with:
name: release
path: dist/*
if-no-files-found: error
homebrew:
needs: prepare
strategy:
fail-fast: false
matrix:
os: [macos-14, macos-15-intel, ubuntu-22.04, ubuntu-22.04-arm]
runs-on: ${{ matrix.os }}
timeout-minutes: 15
env:
HOMEBREW_NO_AUTO_UPDATE: '1'
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0
with:
name: release
path: dist
- name: Install and test the formula against staged archives
shell: bash
run: |
if [ -x /home/linuxbrew/.linuxbrew/bin/brew ]; then
eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)"
fi
tap="$(brew --repository)/Library/Taps/devdotfast/homebrew-tap"
mkdir -p "$tap/Formula"
python3 - "$tap/Formula/diffr.rb" <<'PYTHON'
from pathlib import Path
import re
import sys
formula = Path("dist/diffr.rb").read_text()
formula = re.sub(r'https://github.com/devdotfast/diffr/releases/download/[^/]+/', Path("dist").resolve().as_uri() + "/", formula)
Path(sys.argv[1]).write_text(formula)
PYTHON
brew install devdotfast/tap/diffr
brew test devdotfast/tap/diffr
python3 - "$tap/Formula/diffr.rb" <<'PYTHON'
from pathlib import Path
import sys
path = Path(sys.argv[1])
path.write_text(path.read_text().replace(' license ', ' revision 1\n license ', 1))
PYTHON
brew upgrade devdotfast/tap/diffr
brew test devdotfast/tap/diffr
python3 xtask/tests/smoke_install.py "$(brew --prefix devdotfast/tap/diffr)"
brew uninstall devdotfast/tap/diffr
packaging:
name: Release packaging
if: always()
needs: [build, prepare, homebrew]
runs-on: ubuntu-22.04
steps:
- name: Require all packaging checks to pass
env:
BUILD: ${{ needs.build.result }}
PREPARE: ${{ needs.prepare.result }}
HOMEBREW: ${{ needs.homebrew.result }}
run: test "$BUILD" = success && test "$PREPARE" = success && test "$HOMEBREW" = success
publish:
if: github.event_name == 'push' && github.ref_type == 'tag'
needs: packaging
permissions:
contents: write
runs-on: ubuntu-22.04
steps:
- uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0
with:
name: release
path: dist
- name: Publish complete release
env:
GH_TOKEN: ${{ github.token }}
GH_REPO: ${{ github.repository }}
RELEASE_TAG: ${{ github.ref_name }}
run: |
gh release create "$RELEASE_TAG" dist/* --verify-tag --draft --title "$RELEASE_TAG" --generate-notes
gh release edit "$RELEASE_TAG" --draft=false --latest