diff --git a/.chglog/config.yml b/.chglog/config.yml index 44299ef..8b0a656 100644 --- a/.chglog/config.yml +++ b/.chglog/config.yml @@ -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 diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..bcebe97 --- /dev/null +++ b/.github/workflows/release.yml @@ -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<> $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 }} diff --git a/flake.nix b/flake.nix index 524d021..0b2a70c 100644 --- a/flake.nix +++ b/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"; }; }); };