|
4 | 4 | push: |
5 | 5 | tags: |
6 | 6 | - "[0-9]+.*" |
| 7 | + pull_request: |
| 8 | + paths: |
| 9 | + - .github/workflows/release.yml |
| 10 | + - scripts/release.py |
| 11 | + - xtask/** |
| 12 | + - tui/** |
| 13 | + workflow_dispatch: |
7 | 14 |
|
8 | | -jobs: |
9 | | - create-release: |
10 | | - permissions: |
11 | | - contents: write |
12 | | - runs-on: ubuntu-22.04 |
13 | | - steps: |
14 | | - # v4.2.2 |
15 | | - - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 |
16 | | - - uses: taiki-e/create-gh-release-action@eba8ea96c86cca8a37f1b56e94b4d13301fba651 # v1 |
17 | | - with: |
18 | | - # Publish immediately: Review's build downloads the assets by tag. |
19 | | - draft: false |
20 | | - env: |
21 | | - # (required) |
22 | | - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 15 | +permissions: |
| 16 | + contents: read |
23 | 17 |
|
24 | | - upload-assets: |
25 | | - needs: create-release |
26 | | - permissions: |
27 | | - contents: write |
| 18 | +concurrency: |
| 19 | + group: release-${{ github.ref }} |
| 20 | + cancel-in-progress: false |
| 21 | + |
| 22 | +jobs: |
| 23 | + build: |
28 | 24 | strategy: |
29 | 25 | fail-fast: false |
30 | 26 | matrix: |
31 | 27 | include: |
32 | 28 | - target: aarch64-apple-darwin |
33 | | - os: macos-latest |
| 29 | + os: macos-14 |
34 | 30 | - target: x86_64-unknown-linux-gnu |
35 | 31 | os: ubuntu-22.04 |
36 | 32 | runs-on: ${{ matrix.os }} |
| 33 | + timeout-minutes: 45 |
| 34 | + steps: |
| 35 | + - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 |
| 36 | + - uses: oven-sh/setup-bun@0c5077e51419868618aeaa5fe8019c62421857d6 # v2.2.0 |
| 37 | + with: |
| 38 | + bun-version: 1.3.10 |
| 39 | + - uses: dtolnay/rust-toolchain@stable |
| 40 | + - name: Build and package |
| 41 | + env: |
| 42 | + TARGET: ${{ matrix.target }} |
| 43 | + RELEASE_TAG: ${{ github.ref_type == 'tag' && github.ref_name || '' }} |
| 44 | + run: | |
| 45 | + version=$(cargo metadata --no-deps --format-version 1 | jq -r '.packages[] | select(.name == "diffr-cli") | .version') |
| 46 | + if [ -n "$RELEASE_TAG" ] && [ "$RELEASE_TAG" != "$version" ]; then |
| 47 | + echo "Tag $RELEASE_TAG does not match Cargo version $version" >&2 |
| 48 | + exit 1 |
| 49 | + fi |
| 50 | + cargo xtask install --root "$RUNNER_TEMP/install" |
| 51 | + python3 scripts/release.py pack --version "$version" --target "$TARGET" --install "$RUNNER_TEMP/install" --output dist |
| 52 | + - name: Verify extracted archive without Bun or checkout assets |
| 53 | + run: | |
| 54 | + mkdir -p "$RUNNER_TEMP/extracted/bin" |
| 55 | + tar -xzf dist/*.tar.gz -C "$RUNNER_TEMP/extracted/bin" |
| 56 | + python3 xtask/tests/smoke_install.py "$RUNNER_TEMP/extracted" |
| 57 | + - uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2 |
| 58 | + with: |
| 59 | + name: ${{ matrix.target }} |
| 60 | + path: dist/*.tar.gz |
| 61 | + if-no-files-found: error |
| 62 | + |
| 63 | + prepare: |
| 64 | + needs: build |
| 65 | + runs-on: ubuntu-22.04 |
| 66 | + steps: |
| 67 | + - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 |
| 68 | + - uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0 |
| 69 | + with: |
| 70 | + path: dist |
| 71 | + merge-multiple: true |
| 72 | + - name: Generate checksums and Homebrew formula |
| 73 | + run: | |
| 74 | + version=$(sed -n 's/^version = "\([^"]*\)"/\1/p' Cargo.toml | head -1) |
| 75 | + python3 scripts/release.py formula --version "$version" --output dist |
| 76 | + (cd dist && sha256sum --check SHA256SUMS) |
| 77 | + ruby -c dist/diffr.rb |
| 78 | + - uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2 |
| 79 | + with: |
| 80 | + name: release |
| 81 | + path: dist/* |
| 82 | + if-no-files-found: error |
| 83 | + |
| 84 | + homebrew: |
| 85 | + needs: prepare |
| 86 | + strategy: |
| 87 | + fail-fast: false |
| 88 | + matrix: |
| 89 | + os: [macos-14, ubuntu-22.04] |
| 90 | + runs-on: ${{ matrix.os }} |
| 91 | + timeout-minutes: 15 |
| 92 | + env: |
| 93 | + HOMEBREW_NO_AUTO_UPDATE: '1' |
| 94 | + steps: |
| 95 | + - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 |
| 96 | + - uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0 |
| 97 | + with: |
| 98 | + name: release |
| 99 | + path: dist |
| 100 | + - name: Install and test the formula against staged archives |
| 101 | + shell: bash |
| 102 | + run: | |
| 103 | + if [ -x /home/linuxbrew/.linuxbrew/bin/brew ]; then |
| 104 | + eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)" |
| 105 | + fi |
| 106 | + tap="$(brew --repository)/Library/Taps/devdotfast/homebrew-tap" |
| 107 | + mkdir -p "$tap/Formula" |
| 108 | + python3 - "$tap/Formula/diffr.rb" <<'PYTHON' |
| 109 | + from pathlib import Path |
| 110 | + import re |
| 111 | + import sys |
| 112 | + formula = Path("dist/diffr.rb").read_text() |
| 113 | + formula = re.sub(r'https://github.com/devdotfast/diffr/releases/download/[^/]+/', Path("dist").resolve().as_uri() + "/", formula) |
| 114 | + Path(sys.argv[1]).write_text(formula) |
| 115 | + PYTHON |
| 116 | + brew install devdotfast/tap/diffr |
| 117 | + brew test devdotfast/tap/diffr |
| 118 | + python3 - "$tap/Formula/diffr.rb" <<'PYTHON' |
| 119 | + from pathlib import Path |
| 120 | + import sys |
| 121 | + path = Path(sys.argv[1]) |
| 122 | + path.write_text(path.read_text().replace(' license ', ' revision 1\n license ', 1)) |
| 123 | + PYTHON |
| 124 | + brew upgrade devdotfast/tap/diffr |
| 125 | + brew test devdotfast/tap/diffr |
| 126 | + python3 xtask/tests/smoke_install.py "$(brew --prefix devdotfast/tap/diffr)" |
| 127 | + brew uninstall devdotfast/tap/diffr |
| 128 | +
|
| 129 | + publish: |
| 130 | + if: github.event_name == 'push' && github.ref_type == 'tag' |
| 131 | + needs: homebrew |
| 132 | + permissions: |
| 133 | + contents: write |
| 134 | + runs-on: ubuntu-22.04 |
37 | 135 | steps: |
38 | | - # v4.2.2 |
39 | | - - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 |
40 | | - - uses: taiki-e/upload-rust-binary-action@f0d45ae91ee7b8ee928de7a9d04d893a08bcbec6 # v1.30.2 |
| 136 | + - uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0 |
41 | 137 | with: |
42 | | - bin: diffr |
43 | | - archive: $bin-$tag-$target |
44 | | - # Ensure we respect Cargo.lock in release builds, so the |
45 | | - # released versions match those tested in CI. |
46 | | - locked: true |
47 | | - # (optional) On which platform to distribute the `.tar.gz` file. |
48 | | - tar: unix |
49 | | - # (optional) On which platform to distribute the `.zip` file. |
50 | | - zip: windows |
51 | | - # (optional) Target triple, default is host triple. |
52 | | - target: ${{ matrix.target }} |
| 138 | + name: release |
| 139 | + path: dist |
| 140 | + - name: Publish complete release |
53 | 141 | env: |
54 | | - # (required) |
55 | | - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 142 | + GH_TOKEN: ${{ github.token }} |
| 143 | + GH_REPO: ${{ github.repository }} |
| 144 | + RELEASE_TAG: ${{ github.ref_name }} |
| 145 | + run: | |
| 146 | + gh release create "$RELEASE_TAG" dist/* --verify-tag --draft --title "$RELEASE_TAG" --generate-notes |
| 147 | + gh release edit "$RELEASE_TAG" --draft=false --latest |
0 commit comments