feat: generate changelogs and build binaries with nix
This commit is contained in:
parent
c0397dbff8
commit
81da08cd30
3 changed files with 73 additions and 2 deletions
|
|
@ -2,7 +2,7 @@ style: github
|
|||
template: CHANGELOG.tpl.md
|
||||
info:
|
||||
title: CHANGELOG
|
||||
repository_url: https://github.com/div-search/di-tui
|
||||
repository_url: https://github.com/acaloiaro/di-tui
|
||||
options:
|
||||
commits:
|
||||
filters:
|
||||
|
|
@ -11,8 +11,10 @@ options:
|
|||
- fix
|
||||
- perf
|
||||
- refactor
|
||||
- docs
|
||||
commit_groups:
|
||||
title_maps:
|
||||
docs: Documentation
|
||||
feat: Features
|
||||
fix: Bug Fixes
|
||||
perf: Performance Improvements
|
||||
|
|
|
|||
55
.github/workflows/release.yml
vendored
Normal file
55
.github/workflows/release.yml
vendored
Normal file
|
|
@ -0,0 +1,55 @@
|
|||
name: Release
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
|
||||
jobs:
|
||||
release:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v3
|
||||
with:
|
||||
fetch-depth: 0 # a full history is required for git-chglog
|
||||
|
||||
- name: Install Nix
|
||||
uses: cachix/install-nix-action@v20
|
||||
with:
|
||||
nix_path: nixpkgs=channel:nixos-unstable
|
||||
|
||||
- name: Generate changelog
|
||||
id: changelog
|
||||
run: |
|
||||
changelog=$(nix develop --impure --command git-chglog --next-tag=$(svu next))
|
||||
echo "$changelog" > CHANGELOG.md
|
||||
echo "changelog<<EOF" >> $GITHUB_OUTPUT
|
||||
echo "$changelog" >> $GITHUB_OUTPUT
|
||||
echo "EOF" >> $GITHUB_OUTPUT
|
||||
|
||||
- name: Build binaries
|
||||
run: |
|
||||
nix develop --impure --command bash -c '
|
||||
export CGO_ENABLED=0
|
||||
targets="linux/amd64 linux/arm64 darwin/amd64 darwin/arm64"
|
||||
for target in $targets; do
|
||||
os=$(dirname $target)
|
||||
arch=$(basename $target)
|
||||
output_name="di-tui-${os}-${arch}"
|
||||
echo "Building for $os/$arch..."
|
||||
GOOS=$os GOARCH=$arch go build -o $output_name main.go
|
||||
done
|
||||
'
|
||||
|
||||
- name: Create Release
|
||||
run: |
|
||||
gh release create ${{ steps.version.outputs.version }} \
|
||||
--title "${{ steps.version.outputs.version }}" \
|
||||
--notes "${{ steps.changelog.outputs.changelog }}" \
|
||||
di-tui-linux-amd64 \
|
||||
di-tui-linux-arm64 \
|
||||
di-tui-darwin-amd64 \
|
||||
di-tui-darwin-arm64
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
16
flake.nix
16
flake.nix
|
|
@ -63,16 +63,30 @@
|
|||
pass_filenames = false;
|
||||
entry = "${gomod2nix.legacyPackages.${system}.gomod2nix}/bin/gomod2nix";
|
||||
};
|
||||
pre-commit.hooks.changelog = {
|
||||
enable = true;
|
||||
always_run = true;
|
||||
name = "change";
|
||||
description = "Generate a changelog";
|
||||
pass_filenames = false;
|
||||
entry = "nix .#changelog";
|
||||
};
|
||||
}
|
||||
];
|
||||
};
|
||||
});
|
||||
apps = forEachSystem (system: let
|
||||
pkgs = nixpkgs.legacyPackages.${system};
|
||||
changelog-script = pkgs.writeShellScriptBin "changelog" ''
|
||||
set -euo pipefail
|
||||
current_tag=$(${pkgs.svu}/bin/svu current)
|
||||
${pkgs.git-chglog}/bin/git-chglog "$current_tag"
|
||||
echo "Generated CHANGELOG.md from $current_tag"
|
||||
'';
|
||||
in {
|
||||
changelog = {
|
||||
type = "app";
|
||||
program = "${pkgs.git-chglog}/bin/git-chglog";
|
||||
program = "${changelog-script}/bin/changelog";
|
||||
};
|
||||
});
|
||||
};
|
||||
|
|
|
|||
Loading…
Reference in a new issue