3
3
4
4
# Run when PRs to main are closed.
5
5
on :
6
- pull_request :
6
+ pull_request_target :
7
7
types :
8
8
- closed
9
9
branches :
24
24
steps :
25
25
- run : |
26
26
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"
28
28
29
29
- name : Comment on PR with link to this action
30
30
uses : peter-evans/create-or-update-comment@v2
@@ -45,16 +45,16 @@ jobs:
45
45
- name : Checkout code
46
46
uses : actions/checkout@v3
47
47
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
53
54
54
55
- name : Get version number
55
56
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"
58
58
59
59
build :
60
60
name : Release Build
@@ -67,75 +67,24 @@ jobs:
67
67
runs-on : ${{ matrix.os }}
68
68
strategy :
69
69
matrix :
70
- os : [ubuntu-latest, macos-latest ]
70
+ os : [ubuntu-latest]
71
71
steps :
72
72
- name : Checkout code
73
73
uses : actions/checkout@v3
74
74
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
129
76
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
132
81
133
82
- name : Publish to crates.io
134
83
if : runner.os == 'Linux'
135
84
env :
136
85
CARGO_REGISTRY_TOKEN : ${{ secrets.CARGO_REGISTRY_TOKEN }}
137
86
run : |
138
- cargo publish
87
+ nix run .#pkgs.x86_64-linux. cargo -- publish --no-verify
139
88
140
89
upload :
141
90
name : Upload assets to release
@@ -180,9 +129,6 @@ jobs:
180
129
prerelease : false
181
130
generate_release_notes : true
182
131
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
186
132
187
133
- name : Comment on PR with link to the release
188
134
uses : peter-evans/create-or-update-comment@v2
0 commit comments