From 87f06e30f87aab7dc94aab5620d18e0c43058839 Mon Sep 17 00:00:00 2001 From: Bryton Hall Date: Mon, 9 Jan 2023 02:59:50 -0500 Subject: [PATCH] add changelog for version source of truth --- .github/workflows/main.yml | 18 +++++++++++++++--- CHANGELOG.md | 14 ++++++++++++++ CONTRIBUTING.md | 5 +++++ flake.nix | 5 +++-- 4 files changed, 37 insertions(+), 5 deletions(-) create mode 100644 CHANGELOG.md diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index ce1ec76..6b3fefc 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -3,7 +3,7 @@ on: pull_request: push: jobs: - build: + main: runs-on: ubuntu-latest steps: - name: checkout @@ -18,9 +18,21 @@ jobs: run: nix flake check - name: build run: nix build + - name: bump + id: bump + if: github.ref == 'refs/heads/main' + run: | + latest=$(git tag | sort -n | tail -1) + version=$(cat CHANGELOG.md | grep '^## \[[0-9]' | head -1 | cut -d "[" -f2 | cut -d "]" -f1) + if [[ "$version" != "$latest" ]]; then + git tag $version + git push --tags -o ci.skip + echo version=$version >> $GITHUB_OUTPUT + fi - name: release uses: softprops/action-gh-release@v1 - if: startsWith(github.ref, 'refs/tags/') || github.ref == 'refs/heads/main' + if: steps.bump.outputs.version with: - prerelease: true # TODO: version things + prerelease: true # TODO: make conditional files: result/little-buddy*.bin + tag_name: ${{ steps.bump.outputs.version }} diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..8b45160 --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,14 @@ +# Changelog + +All notable changes to this project will be documented in this file. + +The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), +and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). + +## [Unreleased] + +## [0.0.0] - 2023-01-09 + +### Added + +- init from upstream SDK release on Pine64's wiki diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 1cfb2e3..59bb6ff 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -25,6 +25,11 @@ flashrom -p pony_spi:dev=/dev/ttyACM0 -w out/open_source/open_source.bin minicom -D /dev/ttyACM0 ``` +## release + +Create a new release by moving the "Unreleased" section in [`CHANGELOG.md`](./CHANGELOG.md) to a new version. +Once pushed the [`main.yml`](./.github/workflows/main.yml) workflow will create a new release. + ## notes > **NOTE**: upstream wrote this; leaving until I better understand diff --git a/flake.nix b/flake.nix index 2c8e846..2b41496 100644 --- a/flake.nix +++ b/flake.nix @@ -16,7 +16,6 @@ { packages.default = pkgs.stdenv.mkDerivation rec { name = "little-buddy"; - version = "0.0.0"; # TODO: get version from tags? src = ./.; makeFlags = [ # "-j" @@ -32,8 +31,10 @@ minicom ]; installPhase = '' + version=$(cat CHANGELOG.md | grep '^## \[[0-9]' | head -1 | cut -d "[" -f2 | cut -d "]" -f1) + mkdir -p $out - mv ./out/open_source/open_source.bin $out/${name}-${version}.bin + mv ./out/open_source/open_source.bin $out/${name}-$version.bin ''; }; });