Skip to content

Commit

Permalink
Add cross-compiled build artifacts
Browse files Browse the repository at this point in the history
Squashed commit of the following:

commit b5ad42f
Author: Brian Romanko <[email protected]>
Date:   Mon Feb 26 15:53:05 2024 -0800

    Add workflow step to make releases

commit 582c912
Author: Brian Romanko <[email protected]>
Date:   Mon Feb 26 13:45:36 2024 -0800

    Make artifact name unique

commit 9c126f6
Author: Brian Romanko <[email protected]>
Date:   Mon Feb 26 13:41:25 2024 -0800

    Store build output as artifact

commit c142a6c
Author: Brian Romanko <[email protected]>
Date:   Mon Feb 26 13:03:07 2024 -0800

    Remove verify step

commit c3f4155
Author: Brian Romanko <[email protected]>
Date:   Mon Feb 26 12:59:55 2024 -0800

    See what's in the build output

commit 0746270
Author: Brian Romanko <[email protected]>
Date:   Mon Feb 26 12:58:29 2024 -0800

    Fix typo in build command

commit 3838d33
Author: Brian Romanko <[email protected]>
Date:   Mon Feb 26 12:57:33 2024 -0800

    Pass package target from build matrix

commit e37fee6
Author: Brian Romanko <[email protected]>
Date:   Mon Feb 26 12:49:45 2024 -0800

    Add build flavors

commit 452fa1b
Author: Brian Romanko <[email protected]>
Date:   Mon Feb 26 11:53:43 2024 -0800

    Disable CGO by default

commit 0ff0d0d
Author: Brian Romanko <[email protected]>
Date:   Mon Feb 26 11:52:06 2024 -0800

    Use nix module

commit 70ea0ff
Author: Brian Romanko <[email protected]>
Date:   Mon Feb 26 11:49:19 2024 -0800

    Create nix module for age-plugin-op
  • Loading branch information
bromanko committed Feb 27, 2024
1 parent 0a9c2ff commit c9d04a2
Show file tree
Hide file tree
Showing 3 changed files with 62 additions and 16 deletions.
36 changes: 26 additions & 10 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,11 @@ jobs:

strategy:
matrix:
include:
- {GOOS: linux, GOARCH: amd64}
- {GOOS: linux, GOARCH: arm, GOARM: 6}
- {GOOS: linux, GOARCH: arm64}
- {GOOS: darwin, GOARCH: amd64 }
- {GOOS: darwin, GOARCH: arm64 }
package: [ "age-plugin-op-linux-arm64", "age-plugin-op-linux-arm32", "age-plugin-op-linux-amd64",
"age-plugin-op-darwin-amd64", "age-plugin-op-darwin-arm64" ]

steps:
- name: Checkout repository
- name: Checkout Repository
uses: actions/checkout@v4

- name: Install Nix
Expand All @@ -35,7 +31,27 @@ jobs:
diagnostic-endpoint: ""

- name: Build
run: nix build -L
run: nix build .#${{ matrix.package }} -L

- name: Verify build
run: ./result/bin/age-plugin-op --help
- name: Upload Artifacts
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.package }}
path: result/**/age-plugin-op*
if-no-files-found: error

upload:
name: Upload Release Binaries
if: github.event_name == 'release'
needs: build
permissions:
contents: write
runs-on: ubuntu-latest
steps:
- name: Download Build Artifacts
uses: actions/download-artifact@v4
- name: Upload Release Artifacts
run: gh release upload "$GITHUB_REF_NAME" age-plugin-op-*
env:
GH_REPO: ${{ github.repository }}
GH_TOKEN: ${{ github.token }}
34 changes: 28 additions & 6 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,34 @@
packages = forAllSystems (system:
let pkgs = nixpkgsFor.${system};
in {
age-plugin-op = pkgs.buildGoModule {
pname = "age-plugin-op";
inherit version;
src = ./.;
vendorHash = "sha256-dhJdLYy/CDqZuF5/1v05/ZEp+cWJ6V4GnVCf+mUr1MU=";
};
age-plugin-op = pkgs.callPackage ./nix/age-plugin-op.nix { };

age-plugin-op-linux-arm64 =
(pkgs.callPackage ./nix/age-plugin-op.nix { }).overrideAttrs (old: {
GOOS = "linux";
GOARCH = "arm64";
});
age-plugin-op-linux-arm32 =
(pkgs.callPackage ./nix/age-plugin-op.nix { }).overrideAttrs (old: {
GOOS = "linux";
GOARCH = "arm";
GOARM = "6";
});
age-plugin-op-linux-amd64 =
(pkgs.callPackage ./nix/age-plugin-op.nix { }).overrideAttrs (old: {
GOOS = "linux";
GOARCH = "amd64";
});
age-plugin-op-darwin-amd64 =
(pkgs.callPackage ./nix/age-plugin-op.nix { }).overrideAttrs (old: {
GOOS = "darwin";
GOARCH = "amd64";
});
age-plugin-op-darwin-arm64 =
(pkgs.callPackage ./nix/age-plugin-op.nix { }).overrideAttrs (old: {
GOOS = "darwin";
GOARCH = "arm64";
});
});

devShells = forAllSystems (system:
Expand Down
8 changes: 8 additions & 0 deletions nix/age-plugin-op.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{ pkgs, ... }:
pkgs.buildGoModule {
pname = "age-plugin-op";
version = "0.1.0";
src = ../.;
vendorHash = "sha256-dhJdLYy/CDqZuF5/1v05/ZEp+cWJ6V4GnVCf+mUr1MU=";
CGO_ENABLED = 0;
}

0 comments on commit c9d04a2

Please sign in to comment.