forked from callum-oakley/json5-to-json
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
dev: Setup an automated release process (#1)
- Loading branch information
Showing
11 changed files
with
343 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
targets = [{ triple = "x86_64-unknown-linux-musl" }] | ||
|
||
[advisories] | ||
db-path = "~/.cargo/advisory-db" | ||
db-urls = ["https://github.com/rustsec/advisory-db"] | ||
vulnerability = "deny" | ||
unmaintained = "warn" | ||
yanked = "deny" | ||
notice = "warn" | ||
ignore = [] | ||
|
||
[licenses] | ||
unlicensed = "deny" | ||
allow = ["Apache-2.0", "MIT", "ISC"] | ||
deny = [] | ||
copyleft = "deny" | ||
allow-osi-fsf-free = "neither" | ||
default = "deny" | ||
confidence-threshold = 0.8 | ||
exceptions = [ | ||
# The Unicode-DFS--2016 license is necessary for unicode-ident because they | ||
# use data from the unicode tables to generate the tables which are | ||
# included in the application. We do not distribute those data files so | ||
# this is not a problem for us. See https://github.com/dtolnay/unicode-ident/pull/9/files | ||
# for more details. | ||
{ allow = [ | ||
"MIT", | ||
"Apache-2.0", | ||
"Unicode-DFS-2016", | ||
], name = "unicode-ident" }, | ||
] | ||
|
||
|
||
[bans] | ||
multiple-versions = "deny" | ||
wildcards = "deny" | ||
highlight = "all" | ||
deny = [] | ||
skip = [] | ||
skip-tree = [] | ||
|
||
[sources] | ||
unknown-registry = "deny" | ||
unknown-git = "deny" | ||
allow-registry = ["https://github.com/rust-lang/crates.io-index"] | ||
allow-git = [] | ||
|
||
[sources.allow-org] | ||
github = [] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
version: 2 | ||
updates: | ||
- package-ecosystem: cargo | ||
directory: / | ||
schedule: | ||
interval: daily | ||
allow: | ||
- dependency-type: "all" | ||
ignore: | ||
- dependency-name: "clap_derive" | ||
|
||
- package-ecosystem: github-actions | ||
directory: "/" | ||
schedule: | ||
interval: daily |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
name: Actions | ||
|
||
on: | ||
pull_request: | ||
paths: | ||
- .github/workflows/* | ||
|
||
permissions: | ||
contents: read | ||
|
||
jobs: | ||
action-lint: | ||
timeout-minutes: 5 | ||
runs-on: ubuntu-latest | ||
container: ghcr.io/linkerd/dev:v30-tools | ||
steps: | ||
- uses: actions/checkout@2541b1294d2704b0964813337f33b291d3f8596b | ||
- run: just action-lint |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
name: Release | ||
|
||
on: | ||
pull_request: | ||
paths: | ||
- .github/workflows/release.yml | ||
push: | ||
tags: | ||
- 'v*' | ||
|
||
permissions: | ||
contents: write | ||
|
||
env: | ||
CARGO_INCREMENTAL: 0 | ||
CARGO_NET_RETRY: 10 | ||
RUSTFLAGS: "-D warnings" | ||
RUSTUP_MAX_RETRIES: 10 | ||
|
||
jobs: | ||
meta: | ||
timeout-minutes: 5 | ||
runs-on: ubuntu-latest | ||
container: ghcr.io/linkerd/dev:v30-rust | ||
steps: | ||
- id: meta | ||
shell: bash | ||
run: | | ||
set -eu | ||
shopt -s extglob | ||
ref="${{ github.ref }}" | ||
if [[ "$ref" == refs/tags/v+([0-9]).+([0-9]).+([0-9])?(-+([a-z0-9-])) ]]; then | ||
tv=${ref##refs/tags/} | ||
cv=$(just --evaluate version) | ||
if [ "${tv#v}" != "$cv" ]; then | ||
echo "::error ::Crate version v${cv} does not match tag version ${tv}" | ||
exit 1 | ||
fi | ||
echo ::set-output name=version::"$tv" | ||
echo ::set-output name=publish::true | ||
else | ||
sha="${{ github.sha }}" | ||
echo ::set-output name=version::"test-${sha:0:7}" | ||
fi | ||
outputs: | ||
publish: ${{ steps.meta.outputs.publish }} | ||
version: ${{ steps.meta.outputs.version }} | ||
|
||
package: | ||
needs: [meta] | ||
timeout-minutes: 10 | ||
runs-on: ubuntu-latest | ||
container: ghcr.io/linkerd/dev:v30-rust | ||
steps: | ||
- uses: actions/checkout@2541b1294d2704b0964813337f33b291d3f8596b | ||
- run: just fetch | ||
- run: just build | ||
- run: just package | ||
|
||
- if: needs.meta.outputs.publish == 'true' | ||
uses: softprops/action-gh-release@1e07f4398721186383de40550babbdf2b84acfc5 | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
with: | ||
name: ${{ needs.meta.outputs.version }} | ||
files: target/j5j-${{ needs.meta.outputs.version }}-*.tar.gz | ||
generate_release_notes: true | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
name: Rust | ||
|
||
on: | ||
pull_request: | ||
paths: | ||
- .github/workflows/lint.yml | ||
- Cargo.lock | ||
- '**/*.rs' | ||
|
||
permissions: | ||
contents: read | ||
|
||
env: | ||
CARGO_INCREMENTAL: 0 | ||
CARGO_NET_RETRY: 10 | ||
RUSTFLAGS: "-D warnings" | ||
RUSTUP_MAX_RETRIES: 10 | ||
|
||
jobs: | ||
clippy: | ||
timeout-minutes: 5 | ||
runs-on: ubuntu-latest | ||
container: ghcr.io/linkerd/dev:v30-rust | ||
steps: | ||
- uses: actions/checkout@2541b1294d2704b0964813337f33b291d3f8596b | ||
- run: just fetch | ||
- run: just clippy | ||
|
||
run: | ||
timeout-minutes: 5 | ||
runs-on: ubuntu-latest | ||
container: ghcr.io/linkerd/dev:v30-rust | ||
steps: | ||
- uses: actions/checkout@2541b1294d2704b0964813337f33b291d3f8596b | ||
- run: just fetch | ||
- run: | | ||
[ "$(cargo run --frozen --quiet -- .devcontainer/devcontainer.json | jq -r .name)" = j5j ] | ||
- run: | | ||
[ "$(cargo run --frozen --quiet -- - <.devcontainer/devcontainer.json | jq -r .name)" = j5j ] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,17 @@ | ||
[package] | ||
name = "json5-to-json" | ||
version = "0.1.2" | ||
authors = ["Callum Oakley <[email protected]>"] | ||
name = "j5j" | ||
version = "0.2.0" | ||
description = "A bare-bones tool for converting JSON5 to plain JSON." | ||
license = "ISC" | ||
repository = "https://github.com/callum-oakley/json5-to-json" | ||
repository = "https://github.com/olix0r/j5j" | ||
readme = "README.md" | ||
keywords = ["json5", "to", "json", "translate", "convert"] | ||
edition = "2018" | ||
keywords = ["json5", "json", "translate", "convert"] | ||
edition = "2021" | ||
|
||
[dependencies] | ||
json5 = "0.2" | ||
serde_json = "1.0" | ||
json5 = "0.4" | ||
serde_json = "1" | ||
|
||
[dependencies.clap] | ||
version = "3" | ||
features = ["derive", "env", "std"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
|
||
lint: action-lint clippy | ||
|
||
## | ||
## Rust | ||
## | ||
|
||
# If we're running in github actions and cargo-action-fmt is installed, then add | ||
# a command suffix that formats errors. | ||
_fmt := if env_var_or_default("GITHUB_ACTIONS", "") != "true" { "" } else { | ||
``` | ||
if command -v cargo-action-fmt >/dev/null 2>&1; then | ||
echo "--message-format=json | cargo-action-fmt" | ||
fi | ||
``` | ||
} | ||
|
||
toolchain := "" | ||
|
||
_cargo := "cargo" + if toolchain != "" { " +" + toolchain } else { "" } | ||
|
||
fetch: | ||
{{ _cargo }} fetch --locked | ||
|
||
clippy: fetch | ||
{{ _cargo }} clippy --frozen {{ _fmt }} | ||
|
||
build: fetch | ||
{{ _cargo }} build --frozen --release --target x86_64-unknown-linux-musl {{ _fmt }} | ||
|
||
version := ``` | ||
cargo metadata --format-version=1 \ | ||
| jq -r '.packages[] | select(.name == "j5j") | .version' \ | ||
| head -n 1 | ||
``` | ||
|
||
package: build | ||
tar -czf target/j5j-v{{ version }}-x86_64-unknown-linux-musl.tar.gz \ | ||
-C target/x86_64-unknown-linux-musl/release j5j | ||
|
||
## | ||
## Etc | ||
## | ||
|
||
# Format actionlint output for Github Actions if running in CI. | ||
_actionlint-fmt := if env_var_or_default("GITHUB_ACTIONS", "") != "true" { "" } else { | ||
'{{range $err := .}}::error file={{$err.Filepath}},line={{$err.Line}},col={{$err.Column}}::{{$err.Message}}%0A```%0A{{replace $err.Snippet "\\n" "%0A"}}%0A```\n{{end}}' | ||
} | ||
|
||
# Lints all GitHub Actions workflows | ||
action-lint: | ||
actionlint {{ if _actionlint-fmt != '' { "-format '" + _actionlint-fmt + "'" } else { "" } }} .github/workflows/* |
Oops, something went wrong.