-
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.
* feat: nix * fix: update rust toolchain * feat: add build ci --------- Co-authored-by: Towry <[email protected]>
- Loading branch information
Showing
6 changed files
with
268 additions
and
0 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,75 @@ | ||
name: nix ci | ||
|
||
on: | ||
push: | ||
tags: | ||
- "v[0-9]+.[0-9]+.[0-9]+" | ||
|
||
concurrency: | ||
group: ${{ github.workflow }}-${{ github.ref }} | ||
cancel-in-progress: ${{ github.ref != 'refs/heads/main' }} | ||
|
||
env: | ||
SPEC_SPLIT_DOTS: 160 | ||
CI_NIX_SHELL: true | ||
|
||
jobs: | ||
release-build: | ||
strategy: | ||
matrix: | ||
include: | ||
- target: x86_64-apple-darwin | ||
os: macOS-latest | ||
name: path-git-format-${{ github.ref_name }}-x86_64-darwin.tar.gz | ||
arch: x86_64 | ||
|
||
- target: aarch64-apple-darwin | ||
os: macOS-latest | ||
name: path-git-format-${{ github.ref_name }}-aarch64-darwin.tar.gz | ||
arch: aarch64 | ||
useDaemon: [false, false] | ||
runs-on: ${{ matrix.os }} | ||
steps: | ||
- name: Download source | ||
uses: actions/checkout@v4 | ||
- uses: cachix/install-nix-action@v26 | ||
with: | ||
install_url: https://releases.nixos.org/nix/nix-2.9.2/install | ||
extra_nix_config: | | ||
experimental-features = nix-command flakes | ||
- uses: cachix/cachix-action@v14 | ||
if: ${{ success() }} | ||
with: | ||
name: towry | ||
useDaemon: ${{ matrix.useDaemon }} | ||
authToken: "${{ secrets.CACHIX_AUTH_TOKEN }}" | ||
- name: Enter env | ||
run: nix develop | ||
- name: build | ||
if: ${{ success() }} | ||
run: make release && tar -czvf ${{ matrix.name }} -C ./target/release/ path-git-format | ||
- uses: actions/upload-artifact@v4 | ||
with: | ||
name: ${{ matrix.name }} | ||
path: | | ||
./path-git-format*.tar.gz | ||
retention-days: 1 | ||
|
||
release: | ||
permissions: | ||
contents: write | ||
runs-on: ubuntu-latest | ||
needs: [release-build] | ||
steps: | ||
- uses: actions/download-artifact@v4 | ||
with: | ||
merge-multiple: true | ||
|
||
- name: Release | ||
uses: softprops/action-gh-release@v1 | ||
if: startsWith(github.ref, 'refs/tags/') | ||
with: | ||
draft: true | ||
files: | | ||
path-git-*.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,24 @@ | ||
on: [push] | ||
|
||
name: CI | ||
|
||
jobs: | ||
check: | ||
name: Rust project | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- name: Install latest nightly | ||
uses: actions-rs/toolchain@v1 | ||
with: | ||
toolchain: nightly | ||
override: true | ||
components: rustfmt, clippy | ||
|
||
# `cargo check` command here will use installed `nightly` | ||
# as it is set as an "override" for current directory | ||
|
||
- name: Run cargo check | ||
uses: actions-rs/cargo@v1 | ||
with: | ||
command: check |
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,63 @@ | ||
{ | ||
description = "path-git-format"; | ||
|
||
inputs = { | ||
nixpkgs.url = "github:nixos/nixpkgs?ref=nixos-unstable"; | ||
flake-utils.url = "github:numtide/flake-utils"; | ||
fenix = { | ||
url = "github:nix-community/fenix"; | ||
inputs.nixpkgs.follows = "nixpkgs"; | ||
}; | ||
}; | ||
|
||
outputs = { | ||
self, | ||
nixpkgs, | ||
flake-utils, | ||
fenix, | ||
}: | ||
flake-utils.lib.eachDefaultSystem (system: let | ||
pkgs = nixpkgs.legacyPackages.${system}; | ||
manifest = (nixpkgs.lib.importTOML ./Cargo.toml).package; | ||
rust = fenix.packages.${system}.fromToolchainFile { | ||
dir = ./.; | ||
sha256 = "sha256-jUR2Sd3jhDJIvcuMLBgxtTqa3ELWF38V7IqoZT8EzVU="; | ||
# sha256 = nixpkgs.lib.fakeSha256; | ||
}; | ||
buildInputs = | ||
[ | ||
pkgs.openssl | ||
] | ||
++ nixpkgs.lib.optionals pkgs.stdenv.isDarwin [pkgs.libiconv pkgs.darwin.apple_sdk.frameworks.Security]; | ||
in { | ||
devShells.default = pkgs.mkShell { | ||
packages = [rust pkgs.pkg-config]; | ||
buildInputs = buildInputs; | ||
}; | ||
packages = { | ||
default = pkgs.stdenv.mkDerivation { | ||
pname = "${manifest.name}"; | ||
version = "${manifest.version}"; | ||
src = self; | ||
nativeBuildInputs = [rust pkgs.pkg-config]; | ||
buildInputs = buildInputs; | ||
|
||
buildPhase = '' | ||
export HOME=$(pwd) | ||
cargo --version | ||
make release | ||
''; | ||
installPhase = '' | ||
mkdir -p $out/bin | ||
cp ./target/release/path-git-format $out/bin/ | ||
tar -czvf path-git-format.tar.gz -C ./target/release/ path-git-format | ||
''; | ||
meta = { | ||
description = "A simple utility to format path with git repo info from stdin"; | ||
homepage = "https://github.com/towry/path-git-format"; | ||
license = pkgs.lib.licenses.unlicense; | ||
}; | ||
}; | ||
}; | ||
}); | ||
} |
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,5 @@ | ||
[toolchain] | ||
channel = "nightly-2024-05-02" | ||
components = ["clippy", "rustfmt"] | ||
profile = "default" | ||
targets = [] |