Skip to content

Commit ff84b4a

Browse files
committed
update release flow
1 parent bbe5470 commit ff84b4a

File tree

1 file changed

+60
-10
lines changed

1 file changed

+60
-10
lines changed

.github/workflows/build-scuffle.yaml

Lines changed: 60 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -19,21 +19,24 @@ jobs:
1919
arch: x86_64
2020
- runner: ubuntu-22.04-arm
2121
os: linux
22-
arch: arm64
22+
arch: aarch64
2323
- runner: windows-2022
2424
os: windows
2525
arch: x86_64
26+
- runner: windows-11-arm
27+
os: windows
28+
arch: aarch64
2629
- runner: macos-13
27-
os: macos
30+
os: darwin
2831
arch: x86_64
2932
- runner: macos-14
30-
os: macos
31-
arch: arm64
33+
os: darwin
34+
arch: aarch64
3235
runs-on: ${{ matrix.runner }}
3336
env:
34-
BIN_EXT: ${{ matrix.os == 'windows' && '.exe' || '' }}
37+
NAME: "cargo-bazel-${{ matrix.os }}-${{ matrix.arch }}"
3538
steps:
36-
- uses: actions/checkout@v5
39+
- uses: actions/checkout@v4
3740

3841
- name: Install rust toolchains for host
3942
run: |
@@ -45,26 +48,73 @@ jobs:
4548
run: cargo build -r -p cargo-bazel
4649
working-directory: ./crate_universe
4750

51+
- name: Generate archive with BUILD
52+
run: |
53+
mkdir -p artifacts-archive
54+
BIN_NAME="cargo-bazel${{ runner.os == 'Windows' && '.exe' || '' }}"
55+
56+
mkdir -p "${NAME}"
57+
cp "./crate_universe/target/release/$BIN_NAME" "${NAME}/"
58+
59+
cat > "${NAME}/BUILD" <<EOF
60+
filegroup(
61+
name = "cargo-bazel",
62+
srcs = ["${BIN_NAME}"],
63+
visibility = ["//visibility:public"],
64+
)
65+
EOF
66+
67+
tar -cf - "${NAME}" | zstd --ultra -22 -o "artifacts-archive/$NAME.tar.zst"
68+
4869
- name: Upload artifact
4970
uses: actions/upload-artifact@v4
5071
with:
51-
name: cargo-bazel-${{ matrix.os }}-${{ matrix.arch }}${{ env.BIN_EXT }}
52-
path: ./crate_universe/target/release/cargo-bazel${{ env.BIN_EXT }}
72+
name: ${{ env.NAME }}.tar.zst
73+
path: artifacts-archive/${{ env.NAME }}.tar.zst
5374

5475
release:
5576
needs: builds
5677
runs-on: ubuntu-22.04
78+
permissions:
79+
contents: write
5780
steps:
5881
- name: Download artifacts
59-
uses: actions/download-artifact@v5
82+
uses: actions/download-artifact@v4
6083
with:
6184
path: ./artifacts
6285

86+
- name: Generate release body
87+
run: |
88+
echo 'http_archive = use_repo_rule("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")' > release_body.txt
89+
echo "" >> release_body.txt
90+
91+
for archive in ./artifacts/*.tar.zst; do
92+
FILE_NAME=$(basename "$archive")
93+
SHA=$(sha256sum "$archive" | awk '{print $1}')
94+
NAME="${FILE_NAME%.tar.zst}"
95+
URL="https://github.com/${{ github.repository }}/releases/download/commit-${{ github.sha }}/$FILE_NAME"
96+
STRIP_PREFIX="$NAME"
97+
98+
cat >> release_body.txt <<EOF
99+
http_archive(
100+
name = "$NAME",
101+
sha256 = "$SHA",
102+
strip_prefix = "$STRIP_PREFIX",
103+
url = "$URL",
104+
)
105+
EOF
106+
107+
echo "" >> release_body.txt
108+
done
109+
110+
cat release_body.txt
111+
63112
- name: Create GitHub Release
64113
uses: softprops/action-gh-release@v2
65114
with:
66115
tag_name: commit-${{ github.sha }}
67116
name: "cargo-bazel build for ${{ github.sha }}"
68-
files: ./artifacts/**/*
117+
body_path: release_body.txt
118+
files: ./artifacts/*.tar.zst
69119
env:
70120
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 commit comments

Comments
 (0)