Skip to content

Commit 889bf1d

Browse files
authored
new: Prepare v1 release. (#9)
1 parent 711a320 commit 889bf1d

File tree

9 files changed

+592
-450
lines changed

9 files changed

+592
-450
lines changed

.eslintrc.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,7 @@ module.exports = {
77
project: 'tsconfig.json',
88
tsconfigRootDir: __dirname,
99
},
10+
rules: {
11+
'unicorn/prefer-top-level-await': 'off',
12+
},
1013
};

.github/workflows/ci.yml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,19 @@ jobs:
1414
- run: npm install -g pnpm
1515
- run: pnpm install
1616
- run: pnpm run check
17+
action:
18+
name: 'Action'
19+
runs-on: ${{ matrix.os }}
20+
strategy:
21+
matrix:
22+
os: [ubuntu-latest, macos-latest, windows-latest]
23+
fail-fast: false
24+
steps:
25+
- uses: actions/checkout@v3
26+
- uses: actions/setup-node@v3
27+
- run: npm install -g pnpm
28+
- run: pnpm install
29+
- run: pnpm run build
30+
- uses: ./ # self
31+
env:
32+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
# 1.0.0
2+
3+
- Will now install `rustup` if it does not exist in the environment.
4+
- Added musl support to `cargo-binstall`.
5+
16
# 0.6.0
27

38
- Breaking: Cargo `bins` must provide the `cargo-` crate prefix manually. This change allows

README.md

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ jobs:
1111
runs-on: ubuntu-latest
1212
steps:
1313
# ...
14-
- uses: moonrepo/setup-rust@v0
14+
- uses: moonrepo/setup-rust@v1
1515
- run: cargo test
1616
```
1717
@@ -51,7 +51,7 @@ The toolchain/channel can also be explicitly configured with the `channel` input
5151
highest precedence.
5252

5353
```yaml
54-
- uses: moonrepo/setup-rust@v0
54+
- uses: moonrepo/setup-rust@v1
5555
with:
5656
channel: '1.65.0'
5757
```
@@ -63,15 +63,15 @@ with the `profile`, `components`, and `targets` inputs respectively. When not de
6363
defaults to `minimal`.
6464

6565
```yaml
66-
- uses: moonrepo/setup-rust@v0
66+
- uses: moonrepo/setup-rust@v1
6767
with:
6868
profile: complete
6969
```
7070

7171
When using components, the input requires a comma separated list of component names.
7272

7373
```yaml
74-
- uses: moonrepo/setup-rust@v0
74+
- uses: moonrepo/setup-rust@v1
7575
with:
7676
components: clippy
7777
- run: cargo clippy --workspace
@@ -80,7 +80,7 @@ When using components, the input requires a comma separated list of component na
8080
When using targets, the input requires a comma separated list of target triples.
8181

8282
```yaml
83-
- uses: moonrepo/setup-rust@v0
83+
- uses: moonrepo/setup-rust@v1
8484
with:
8585
targets: 'x86_64-pc-windows-msvc,x86_64-pc-windows-gnu'
8686
```
@@ -92,13 +92,15 @@ installing Cargo binaries through the `bins` input, which requires a comma-separ
9292
names.
9393

9494
```yaml
95-
- uses: moonrepo/setup-rust@v0
95+
- uses: moonrepo/setup-rust@v1
9696
with:
9797
bins: cargo-nextest, [email protected]
98+
env:
99+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
98100
```
99101

100102
> Binaries are installed with [`cargo-binstall`](https://crates.io/crates/cargo-binstall) under the
101-
> hood.
103+
> hood. We suggest setting `GITHUB_TOKEN` to avoid rate limiting.
102104

103105
## Caching in CI
104106

@@ -107,7 +109,7 @@ CI times. To disable caching, set the `cache` input to `false`. Furthermore, the
107109
be changed with the `cache-target` input, which defaults to `debug`.
108110

109111
```yaml
110-
- uses: moonrepo/setup-rust@v0
112+
- uses: moonrepo/setup-rust@v1
111113
with:
112114
cache: false
113115
cache-target: release
@@ -147,11 +149,6 @@ Outside of being evergreen, this action also supports the following features:
147149
- Assumes `rustup`, `cargo`, and other commands are available globally. This allows you to use them
148150
directly in a `run` command, without having to use `actions-rs/cargo`.
149151

150-
However, this action _does not_:
151-
152-
- Install `rustup` if it does not exist, while `actions-rs` will. This is typically fine if using
153-
GitHub provided runners as all Rust tooling comes pre-installed.
154-
155152
### `dtolnay/rust-toolchain`
156153

157154
Our action is very similar to theirs, which was a great implementation reference, but our action

index.ts

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,38 @@
1-
import path from 'path';
1+
import fs from 'node:fs';
2+
import os from 'node:os';
3+
import path from 'node:path';
24
import * as core from '@actions/core';
5+
import * as exec from '@actions/exec';
6+
import * as io from '@actions/io';
7+
import * as tc from '@actions/tool-cache';
38
import { CARGO_HOME, installBins, restoreCache } from './src/cargo';
49
import { installToolchain } from './src/rust';
510

11+
export async function installRustup() {
12+
try {
13+
await io.which('rustup', true);
14+
return;
15+
} catch {
16+
// Doesn't exist
17+
}
18+
19+
core.info('rustup does not exist, attempting to install');
20+
21+
const script = await tc.downloadTool(
22+
process.platform === 'win32' ? 'https://win.rustup.rs' : 'https://sh.rustup.rs',
23+
path.join(os.tmpdir(), 'rustup-init'),
24+
);
25+
26+
core.info(`Downloaded installation script to ${script}`);
27+
28+
// eslint-disable-next-line no-magic-numbers
29+
await fs.promises.chmod(script, 0o755);
30+
31+
await exec.exec(script, ['--default-toolchain', 'none', '-y']);
32+
33+
core.info('Installed rustup');
34+
}
35+
636
async function run() {
737
core.info('Setting cargo environment variables');
838

@@ -14,6 +44,7 @@ async function run() {
1444
core.addPath(path.join(CARGO_HOME, 'bin'));
1545

1646
try {
47+
await installRustup();
1748
await installToolchain();
1849
await installBins();
1950

package.json

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@moonrepo/setup-rust",
3-
"version": "0.6.1",
3+
"version": "1.0.0",
44
"description": "A GitHub action for setting up Rust and Cargo.",
55
"main": "dist/index.js",
66
"scripts": {
@@ -22,16 +22,20 @@
2222
"@actions/glob": "^0.4.0",
2323
"@actions/io": "^1.1.3",
2424
"@actions/tool-cache": "^2.0.1",
25-
"@ltd/j-toml": "^1.38.0"
25+
"@ltd/j-toml": "^1.38.0",
26+
"detect-libc": "^2.0.2"
2627
},
2728
"devDependencies": {
2829
"@types/node": "^18.15.11",
2930
"@vercel/ncc": "^0.36.1",
30-
"eslint": "^8.40.0",
31-
"eslint-config-moon": "^2.0.3",
32-
"prettier": "^2.8.8",
31+
"eslint": "^8.46.0",
32+
"eslint-config-moon": "^2.0.6",
33+
"prettier": "^3.0.0",
3334
"prettier-config-moon": "^1.1.2",
3435
"tsconfig-moon": "^1.3.0",
35-
"typescript": "^5.0.4"
36+
"typescript": "^5.1.6"
37+
},
38+
"engines": {
39+
"node": ">=16.0.0"
3640
}
3741
}

0 commit comments

Comments
 (0)