Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 37 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: Release

on:
push:
tags:
- "v*"

permissions:
contents: write

jobs:
release:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v5
- uses: cachix/install-nix-action@v31
with:
github_access_token: ${{ secrets.GITHUB_TOKEN }}

- uses: DeterminateSystems/magic-nix-cache-action@main

- id: filenames
run: echo VENDORED_TARBALL="$(nix eval --raw .#packages.x86_64-linux.vendored-tarball-filename)" >> "$GITHUB_OUTPUT"

- run: |
nix build .#vendored-tarball
ln -s result "${{ steps.filenames.outputs.VENDORED_TARBALL }}"

- name: Create GitHub Release (Draft)
uses: softprops/action-gh-release@v2
with:
draft: true
tag_name: ${{ github.ref_name }}
files: ${{ steps.filenames.outputs.VENDORED_TARBALL }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
73 changes: 55 additions & 18 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
nixpkgs,
}:
let
pname = "drasl";
version =
let
buildConfig = builtins.readFile ./build_config.go;
Expand Down Expand Up @@ -51,40 +52,49 @@
packages = forAllSystems (
system:
let
buildDrasl =
npmDeps =
pkgs:
let
nodejs = pkgs.nodejs_20;
npmDeps = pkgs.importNpmLock.buildNodeModules {
inherit nodejs;
npmRoot = ./.;
};
in
pkgs.importNpmLock.buildNodeModules {
inherit nodejs;
npmRoot = ./.;
};

nativeBuildInputs =
pkgs: with pkgs; [
nodejs
go-swag
];

# Update whenever Go dependencies change
vendorHash = "sha256-4Rk59bnDFYpraoGvkBUW6Z5fiXUmm2RLwS1wxScWAMQ=";

preBuild = pkgs: ''
ln -s ${npmDeps pkgs}/node_modules .
make -o npm-install prebuild
'';

buildDrasl =
pkgs:
pkgs.buildGoModule {
pname = "drasl";
inherit pname;
inherit version;

src = ./.;

nativeBuildInputs = with pkgs; [
nodejs
go-swag
];
nativeBuildInputs = nativeBuildInputs pkgs;

# Update whenever Go dependencies change
vendorHash = "sha256-4Rk59bnDFYpraoGvkBUW6Z5fiXUmm2RLwS1wxScWAMQ=";
inherit vendorHash;

outputs = [ "out" ];

preBuild = preBuild pkgs;

preConfigure = ''
substituteInPlace build_config.go --replace-fail "\"/usr/share/drasl\"" "\"$out/share/drasl\""
'';

preBuild = ''
ln -s ${npmDeps}/node_modules .
make -o npm-install prebuild
'';

postInstall = ''
mkdir -p "$out/share/drasl"
cp -R ./{assets,view,public,locales} "$out/share/drasl"
Expand All @@ -98,6 +108,30 @@
contents = with pkgs; [ cacert ];
config.Cmd = [ "${buildDrasl pkgs}/bin/drasl" ];
};

buildVendoredTarball =
pkgs:
pkgs.buildGoModule {
inherit pname;
inherit version;
src = ./.;

nativeBuildInputs = nativeBuildInputs pkgs;

inherit vendorHash;

outputs = [ "out" ];

buildPhase = preBuild pkgs;

doCheck = false;

installPhase = ''
tar -cJf "$out" --exclude node_modules --transform "s|^|$pname-$version/|" .
'';

dontFixup = true;
};
in
rec {
drasl = buildDrasl nixpkgsFor.${system};
Expand All @@ -113,6 +147,9 @@
# oci-cross-x86_64-darwin = buildOCIImage nixpkgsCross.${system}.x86_64-darwin;
oci-cross-aarch64-linux = buildOCIImage nixpkgsCross.${system}.aarch64-linux;
# oci-cross-aarch64-darwin = buildOCIImage nixpkgsCross.${system}.aarch64-darwin;

vendored-tarball = buildVendoredTarball nixpkgsFor.${system};
vendored-tarball-filename = "${vendored-tarball.pname}-${vendored-tarball.version}-vendored.tar.xz";
}
);

Expand Down
Loading