Skip to content

Commit 14b034d

Browse files
committed
Fix GitHub actions & rework Flake
1 parent 6265214 commit 14b034d

15 files changed

+323
-337
lines changed

.config/nextest.toml

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# https://nexte.st/book/configuration.html
2+
3+
[profile.ci]
4+
# Print out output for failing tests as soon as they fail, and also at the end
5+
# of the run (for easy scrollability).
6+
failure-output = "immediate-final"
7+
# Do not cancel the test run on the first failure.
8+
fail-fast = false
9+
# The Garnix CI builders run in some weird virtual filesystem that messes with
10+
# `notify`. Even with sleeps before writing and poll-based notifications,
11+
# sometimes `notify` misses events (this is rare, maybe 1 in 50 test runs).
12+
# Retry tests if they fail in CI to mitigate this.
13+
retries = 3

.github/workflows/ci.yaml

-39
This file was deleted.

.github/workflows/get-crate-version.sh

-15
This file was deleted.

.github/workflows/release.yaml

+16-70
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
# Run when PRs to main are closed.
55
on:
6-
pull_request:
6+
pull_request_target:
77
types:
88
- closed
99
branches:
@@ -24,7 +24,7 @@ jobs:
2424
steps:
2525
- run: |
2626
echo "This is a canonical hack to run GitHub Actions on merged PRs"
27-
echo "See: https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#running-your-workflow-when-a-pull-request-merges"
27+
echo "See: https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#running-your-pull_request-workflow-when-a-pull-request-merges"
2828
2929
- name: Comment on PR with link to this action
3030
uses: peter-evans/create-or-update-comment@v2
@@ -45,16 +45,16 @@ jobs:
4545
- name: Checkout code
4646
uses: actions/checkout@v3
4747

48-
- name: Install rustup
49-
uses: dtolnay/rust-toolchain@stable
50-
51-
- name: Install jq
52-
run: sudo apt install -y jq
48+
- uses: cachix/install-nix-action@v22
49+
with:
50+
github_access_token: ${{ secrets.GITHUB_TOKEN }}
51+
extra_nix_config: |
52+
extra-experimental-features = nix-command flakes
53+
accept-flake-config = true
5354
5455
- name: Get version number
5556
id: get_cargo_metadata
56-
run: |
57-
echo "version=$(./.github/workflows/get-crate-version.sh)" >> "$GITHUB_OUTPUT"
57+
run: echo "version=$(nix run .#get-crate-version)" >> "$GITHUB_OUTPUT"
5858

5959
build:
6060
name: Release Build
@@ -67,75 +67,24 @@ jobs:
6767
runs-on: ${{ matrix.os }}
6868
strategy:
6969
matrix:
70-
os: [ubuntu-latest, macos-latest]
70+
os: [ubuntu-latest]
7171
steps:
7272
- name: Checkout code
7373
uses: actions/checkout@v3
7474

75-
- name: Install rustup
76-
uses: dtolnay/rust-toolchain@stable
77-
if: runner.os == 'macOS'
78-
with:
79-
target: x86_64-apple-darwin, aarch64-apple-darwin
80-
81-
- name: Install rustup
82-
uses: dtolnay/rust-toolchain@stable
83-
if: runner.os == 'Linux'
84-
with:
85-
target: x86_64-unknown-linux-musl, aarch64-unknown-linux-musl
86-
87-
- name: Log versions
88-
run: which -a rustup && rustup --version
89-
90-
- name: Test
91-
run: cargo test
92-
93-
- name: Build (macOS, x86_64)
94-
if: runner.os == 'macOS'
95-
run: cargo build --release --target x86_64-apple-darwin
96-
97-
- name: Build (macOS, aarch64)
98-
if: runner.os == 'macOS'
99-
run: cargo build --release --target aarch64-apple-darwin
100-
101-
- name: Build (Linux, x86_64)
102-
if: runner.os == 'Linux'
103-
run: cargo build --release --target x86_64-unknown-linux-musl
104-
105-
- name: Create macOS universal executable and codesign it
106-
if: runner.os == 'macOS'
107-
run: |
108-
lipo -create -output target/release/nix-your-shell-macos \
109-
target/x86_64-apple-darwin/release/nix-your-shell \
110-
target/aarch64-apple-darwin/release/nix-your-shell
111-
112-
- name: Rename executables for upload
113-
if: runner.os == 'Linux'
114-
run: |
115-
mkdir -p target/release
116-
mv target/x86_64-unknown-linux-musl/release/nix-your-shell \
117-
target/release/nix-your-shell-x86_64-linux
118-
119-
- name: Upload macOS executable
120-
uses: actions/upload-artifact@v3
121-
if: runner.os == 'macOS'
122-
with:
123-
name: macos
124-
path: target/release/nix-your-shell-macos
125-
126-
- name: Upload Linux x86_64 executable
127-
uses: actions/upload-artifact@v3
128-
if: runner.os == 'Linux'
75+
- uses: cachix/install-nix-action@v22
12976
with:
130-
name: linux-x86_64
131-
path: target/release/nix-your-shell-x86_64-linux
77+
github_access_token: ${{ secrets.GITHUB_TOKEN }}
78+
extra_nix_config: |
79+
extra-experimental-features = nix-command flakes
80+
accept-flake-config = true
13281
13382
- name: Publish to crates.io
13483
if: runner.os == 'Linux'
13584
env:
13685
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
13786
run: |
138-
cargo publish
87+
nix run .#pkgs.x86_64-linux.cargo -- publish --no-verify
13988
14089
upload:
14190
name: Upload assets to release
@@ -180,9 +129,6 @@ jobs:
180129
prerelease: false
181130
generate_release_notes: true
182131
tag_name: v${{ needs.version.outputs.version }}
183-
files: |
184-
macos/nix-your-shell-macos
185-
linux-x86_64/nix-your-shell-x86_64-linux
186132

187133
- name: Comment on PR with link to the release
188134
uses: peter-evans/create-or-update-comment@v2

.github/workflows/version.yaml

+14-33
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,13 @@
99
# and update the `REPO_GITHUB_TOKEN` secret to a new, valid token.
1010

1111
on:
12-
pull_request:
12+
pull_request_target:
1313
types:
1414
- closed
1515
branches:
1616
- main
1717

18-
name: Update versions and release
18+
name: Update versions and create release PR
1919

2020
jobs:
2121
# We make `if_merged` a `needs:` of the other jobs here to only run this
@@ -31,7 +31,7 @@ jobs:
3131
steps:
3232
- run: |
3333
echo "This is a canonical hack to run GitHub Actions on merged PRs"
34-
echo "See: https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#running-your-workflow-when-a-pull-request-merges"
34+
echo "See: https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#running-your-pull_request-workflow-when-a-pull-request-merges"
3535
3636
bump_type:
3737
name: Determine version bump type
@@ -56,7 +56,7 @@ jobs:
5656
fi
5757
5858
version:
59-
name: Update and tag version numbers
59+
name: Bump version and create release PR
6060
permissions:
6161
pull-requests: write
6262
needs:
@@ -70,42 +70,23 @@ jobs:
7070
# Fetch all history/tags (needed to compute versions)
7171
fetch-depth: 0
7272

73-
- name: Install rustup
74-
uses: dtolnay/rust-toolchain@stable
75-
76-
- name: Download and install `cargo-release`
77-
run: |
78-
set -v
79-
pushd "$(mktemp -d)"
80-
curl -L -o cargo-release.tar.gz \
81-
https://github.com/crate-ci/cargo-release/releases/download/v0.21.1/cargo-release-v0.21.1-x86_64-unknown-linux-gnu.tar.gz
82-
tar -xvf cargo-release.tar.gz
83-
install -d ~/.local/bin
84-
install cargo-release ~/.local/bin
85-
echo "$HOME/.local/bin" >> "$GITHUB_PATH"
86-
popd
87-
~/.local/bin/cargo-release release --version
73+
- uses: cachix/install-nix-action@v22
74+
with:
75+
github_access_token: ${{ secrets.GITHUB_TOKEN }}
76+
extra_nix_config: |
77+
extra-experimental-features = nix-command flakes
78+
accept-flake-config = true
8879
8980
- name: Get old version number
9081
id: old_cargo_metadata
91-
run: |
92-
echo "version=$(./.github/workflows/get-crate-version.sh)" >> "$GITHUB_OUTPUT"
82+
run: echo "version=$(nix run .#get-crate-version)" >> "$GITHUB_OUTPUT"
9383

9484
- name: Increment `Cargo.toml` version
95-
# `cargo-release` changes the version numbers in `Cargo.toml` and
96-
# `Cargo.lock` and commits the changes.
97-
run: |
98-
git config --local user.email "github-actions[bot]@users.noreply.github.com"
99-
git config --local user.name "github-actions[bot]"
100-
cargo-release release \
101-
--execute \
102-
--no-confirm \
103-
${{ needs.bump_type.outputs.bump_type }}
85+
run: nix run .#make-release-commit -- ${{ needs.bump_type.outputs.bump_type }}
10486

10587
- name: Get new version number
10688
id: new_cargo_metadata
107-
run: |
108-
echo "version=$(./.github/workflows/get-crate-version.sh)" >> "$GITHUB_OUTPUT"
89+
run: echo "version=$(nix run .#get-crate-version)" >> "$GITHUB_OUTPUT"
10990

11091
- name: Create release PR
11192
id: release_pr
@@ -128,7 +109,7 @@ jobs:
128109
labels: release
129110

130111
- name: Comment on PR with link to release PR
131-
uses: peter-evans/create-or-update-comment@v2
112+
uses: peter-evans/create-or-update-comment@v3
132113
with:
133114
issue-number: ${{ github.event.pull_request.number }}
134115
body: |

0 commit comments

Comments
 (0)