new: Prepare v1 release. (#9)

This commit is contained in:
Miles Johnson 2023-08-01 15:29:15 -07:00 committed by GitHub
parent 711a320c49
commit 889bf1db60
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 592 additions and 450 deletions

View file

@ -7,4 +7,7 @@ module.exports = {
project: 'tsconfig.json',
tsconfigRootDir: __dirname,
},
rules: {
'unicorn/prefer-top-level-await': 'off',
},
};

View file

@ -14,3 +14,19 @@ jobs:
- run: npm install -g pnpm
- run: pnpm install
- run: pnpm run check
action:
name: 'Action'
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
fail-fast: false
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
- run: npm install -g pnpm
- run: pnpm install
- run: pnpm run build
- uses: ./ # self
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

View file

@ -1,3 +1,8 @@
# 1.0.0
- Will now install `rustup` if it does not exist in the environment.
- Added musl support to `cargo-binstall`.
# 0.6.0
- Breaking: Cargo `bins` must provide the `cargo-` crate prefix manually. This change allows

View file

@ -11,7 +11,7 @@ jobs:
runs-on: ubuntu-latest
steps:
# ...
- uses: moonrepo/setup-rust@v0
- uses: moonrepo/setup-rust@v1
- run: cargo test
```
@ -51,7 +51,7 @@ The toolchain/channel can also be explicitly configured with the `channel` input
highest precedence.
```yaml
- uses: moonrepo/setup-rust@v0
- uses: moonrepo/setup-rust@v1
with:
channel: '1.65.0'
```
@ -63,7 +63,7 @@ with the `profile`, `components`, and `targets` inputs respectively. When not de
defaults to `minimal`.
```yaml
- uses: moonrepo/setup-rust@v0
- uses: moonrepo/setup-rust@v1
with:
profile: complete
```
@ -71,7 +71,7 @@ defaults to `minimal`.
When using components, the input requires a comma separated list of component names.
```yaml
- uses: moonrepo/setup-rust@v0
- uses: moonrepo/setup-rust@v1
with:
components: clippy
- run: cargo clippy --workspace
@ -80,7 +80,7 @@ When using components, the input requires a comma separated list of component na
When using targets, the input requires a comma separated list of target triples.
```yaml
- uses: moonrepo/setup-rust@v0
- uses: moonrepo/setup-rust@v1
with:
targets: 'x86_64-pc-windows-msvc,x86_64-pc-windows-gnu'
```
@ -92,13 +92,15 @@ installing Cargo binaries through the `bins` input, which requires a comma-separ
names.
```yaml
- uses: moonrepo/setup-rust@v0
- uses: moonrepo/setup-rust@v1
with:
bins: cargo-nextest, cargo-insta@1.28.0
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
```
> Binaries are installed with [`cargo-binstall`](https://crates.io/crates/cargo-binstall) under the
> hood.
> hood. We suggest setting `GITHUB_TOKEN` to avoid rate limiting.
## Caching in CI
@ -107,7 +109,7 @@ CI times. To disable caching, set the `cache` input to `false`. Furthermore, the
be changed with the `cache-target` input, which defaults to `debug`.
```yaml
- uses: moonrepo/setup-rust@v0
- uses: moonrepo/setup-rust@v1
with:
cache: false
cache-target: release
@ -147,11 +149,6 @@ Outside of being evergreen, this action also supports the following features:
- Assumes `rustup`, `cargo`, and other commands are available globally. This allows you to use them
directly in a `run` command, without having to use `actions-rs/cargo`.
However, this action _does not_:
- Install `rustup` if it does not exist, while `actions-rs` will. This is typically fine if using
GitHub provided runners as all Rust tooling comes pre-installed.
### `dtolnay/rust-toolchain`
Our action is very similar to theirs, which was a great implementation reference, but our action

View file

@ -1,8 +1,38 @@
import path from 'path';
import fs from 'node:fs';
import os from 'node:os';
import path from 'node:path';
import * as core from '@actions/core';
import * as exec from '@actions/exec';
import * as io from '@actions/io';
import * as tc from '@actions/tool-cache';
import { CARGO_HOME, installBins, restoreCache } from './src/cargo';
import { installToolchain } from './src/rust';
export async function installRustup() {
try {
await io.which('rustup', true);
return;
} catch {
// Doesn't exist
}
core.info('rustup does not exist, attempting to install');
const script = await tc.downloadTool(
process.platform === 'win32' ? 'https://win.rustup.rs' : 'https://sh.rustup.rs',
path.join(os.tmpdir(), 'rustup-init'),
);
core.info(`Downloaded installation script to ${script}`);
// eslint-disable-next-line no-magic-numbers
await fs.promises.chmod(script, 0o755);
await exec.exec(script, ['--default-toolchain', 'none', '-y']);
core.info('Installed rustup');
}
async function run() {
core.info('Setting cargo environment variables');
@ -14,6 +44,7 @@ async function run() {
core.addPath(path.join(CARGO_HOME, 'bin'));
try {
await installRustup();
await installToolchain();
await installBins();

View file

@ -1,6 +1,6 @@
{
"name": "@moonrepo/setup-rust",
"version": "0.6.1",
"version": "1.0.0",
"description": "A GitHub action for setting up Rust and Cargo.",
"main": "dist/index.js",
"scripts": {
@ -22,16 +22,20 @@
"@actions/glob": "^0.4.0",
"@actions/io": "^1.1.3",
"@actions/tool-cache": "^2.0.1",
"@ltd/j-toml": "^1.38.0"
"@ltd/j-toml": "^1.38.0",
"detect-libc": "^2.0.2"
},
"devDependencies": {
"@types/node": "^18.15.11",
"@vercel/ncc": "^0.36.1",
"eslint": "^8.40.0",
"eslint-config-moon": "^2.0.3",
"prettier": "^2.8.8",
"eslint": "^8.46.0",
"eslint-config-moon": "^2.0.6",
"prettier": "^3.0.0",
"prettier-config-moon": "^1.1.2",
"tsconfig-moon": "^1.3.0",
"typescript": "^5.0.4"
"typescript": "^5.1.6"
},
"engines": {
"node": ">=16.0.0"
}
}

913
pnpm-lock.yaml generated

File diff suppressed because it is too large Load diff

View file

@ -1,7 +1,7 @@
import crypto from 'crypto';
import fs from 'fs';
import os from 'os';
import path from 'path';
import crypto from 'node:crypto';
import fs from 'node:fs';
import os from 'node:os';
import path from 'node:path';
import * as cache from '@actions/cache';
import * as core from '@actions/core';
import * as exec from '@actions/exec';
@ -26,6 +26,9 @@ export async function downloadAndInstallBinstall(binDir: string) {
case 'x64':
arch = 'x86_64';
break;
case 'arm':
arch = 'armv7';
break;
case 'arm64':
arch = 'aarch64';
break;
@ -34,9 +37,21 @@ export async function downloadAndInstallBinstall(binDir: string) {
}
switch (process.platform) {
case 'linux':
file = `${arch}-unknown-linux-gnu.tgz`;
case 'linux': {
const { family } = await import('detect-libc');
let lib = 'gnu';
if ((await family()) === 'musl') {
lib = 'musl';
}
if (process.arch === 'arm') {
lib += 'eabihf';
}
file = `${arch}-unknown-linux-${lib}.tgz`;
break;
}
case 'darwin':
file = `${arch}-apple-darwin.zip`;
break;
@ -220,7 +235,7 @@ export async function restoreCache() {
core.saveState('cache-hit-key', cacheKey);
core.info(`Cache restored using key ${primaryKey}`);
} else {
core.warning(`Cache does not exist using key ${primaryKey}`);
core.info(`Cache does not exist using key ${primaryKey}`);
}
core.setOutput('cache-key', cacheKey ?? primaryKey);

View file

@ -1,7 +1,7 @@
/* eslint-disable import/no-mutable-exports */
import fs from 'fs';
import path from 'path';
import fs from 'node:fs';
import path from 'node:path';
import * as core from '@actions/core';
import * as exec from '@actions/exec';
import TOML from '@ltd/j-toml';