diff --git a/.forgejo/workflows/release.yml b/.forgejo/workflows/release.yml new file mode 100644 index 0000000..ce0a0a7 --- /dev/null +++ b/.forgejo/workflows/release.yml @@ -0,0 +1,37 @@ +name: Release + +on: + push: + tags: + - "v*" + +jobs: + build-and-release: + runs-on: native + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Build with Nix + run: | + nix build .#default --out-link result + cp result/bin/typssg ./typssg-linux-x86_64 + + - name: Create Release and Upload Binary + run: | + TAG="${{ github.ref_name }}" + BINARY="typssg-linux-x86_64" + REPO="${{ github.repository }}" + API="https://your-forgejo-instance.com/api/v1" + TOKEN="${{ secrets.RELEASE_TOKEN }}" + + RELEASE_ID=$(curl -s -X POST "$API/repos/$REPO/releases" \ + -H "Authorization: token $TOKEN" \ + -H "Content-Type: application/json" \ + -d "{\"tag_name\": \"$TAG\", \"name\": \"$TAG\", \"draft\": false}" \ + | jq -r '.id') + + curl -s -X POST "$API/repos/$REPO/releases/$RELEASE_ID/assets?name=$BINARY" \ + -H "Authorization: token $TOKEN" \ + -H "Content-Type: application/octet-stream" \ + --data-binary @$BINARY diff --git a/default.nix b/default.nix new file mode 100644 index 0000000..b343f04 --- /dev/null +++ b/default.nix @@ -0,0 +1,26 @@ +{ pkgs ? import {} }: + +let + rust-overlay = (import (builtins.fetchTarball "https://github.com/oxalica/rust-overlay/archive/master.tar.gz")); + nixpkgs = import { overlays = [ rust-overlay ]; }; + rust-bin = nixpkgs.rust-bin.fromRustupToolchainFile ./rust-toolchain.toml; + rustPlatform = pkgs.makeRustPlatform { + cargo = rust-bin; + rustc = rust-bin; + }; +in +rustPlatform.buildRustPackage { + name = "typssg"; + + src = ./.; + + nativeBuildInputs = with pkgs; [ + rust-analyzer + ]; + buildInputs = []; + + cargoLock.lockFile = ./Cargo.lock; + + RUSTUP_HOME = toString ./.rustup; + CARGO_HOME = toString ./.cargo; +}