From f98b619765b116ace1c8fdc40e16f123c8ba8170 Mon Sep 17 00:00:00 2001 From: patrick brisbin Date: Fri, 21 Feb 2025 11:28:59 -0500 Subject: [PATCH] fix: implement semantic-release automation This involves a few steps that I've kept together for easy reference as an example: 1. Configure semantic release (`.releaserc.yaml`) This uses a custom plugin, which I maintain, to upload with `stack upload` as the main release action. 2. Trigger semantic release in the Release workflow 3. Update `package.yaml` to not have a meaningful version Except the `2.` prefix is there, so my release plugin can infer it. 4. Update the README with release instructions 5. Update CHANGELOG to point to releases This is how semantic-release folks recommend doing it. The Releases (from now own) will have automatically-maintained changelog information. I may backfill previous releases. --- .github/workflows/release.yml | 27 +++++++++++++------- .releaserc.yaml | 15 +++++++++++ CHANGELOG.md | 47 +---------------------------------- graphula.cabal | 4 +-- package.yaml | 2 +- test/README.lhs | 12 +++++++++ 6 files changed, 49 insertions(+), 58 deletions(-) create mode 100644 .releaserc.yaml diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 982f175..9fa37f0 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -2,22 +2,31 @@ name: Release on: push: - branches: main + branches: + - main + - rc/* jobs: release: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 + with: + persist-credentials: false - - id: tag - uses: freckle/haskell-tag-action@v1 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + - id: token + uses: actions/create-github-app-token@v1 + with: + app-id: ${{ vars.FRECKLE_AUTOMATION_APP_ID }} + private-key: ${{ secrets.FRECKLE_AUTOMATION_PRIVATE_KEY }} - - if: steps.tag.outputs.tag - uses: freckle/stack-upload-action@v2 + - id: release + uses: cycjimmy/semantic-release-action@v4 with: - pvp-bounds: lower + extra_plugins: | + git+https://github.com/pbrisbin/semantic-release-stack-upload.git env: - HACKAGE_API_KEY: ${{ secrets.HACKAGE_UPLOAD_API_KEY }} + FORCE_COLOR: 1 + GITHUB_TOKEN: ${{ steps.token.outputs.token }} + HACKAGE_KEY: ${{ secrets.HACKAGE_UPLOAD_API_KEY }} + STACK_YAML: stack-lts-12.26.yaml diff --git a/.releaserc.yaml b/.releaserc.yaml new file mode 100644 index 0000000..12b5435 --- /dev/null +++ b/.releaserc.yaml @@ -0,0 +1,15 @@ +tagFormat: "v2.${version}" # PVP prefixed + +plugins: + - "@semantic-release/commit-analyzer" + - "@semantic-release/release-notes-generator" + - - "@semantic-release/github" + - successCommentCondition: false + - - "semantic-release-stack-upload" + - pvpBounds: lower + stripSuffix: true + +branches: + - main + - name: rc/* + prerelease: '${name.replace(/^rc\//, "rc-")}' diff --git a/CHANGELOG.md b/CHANGELOG.md index a2888d4..771a3e0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,46 +1 @@ -## [_Unreleased_](https://github.com/freckle/graphula/compare/v2.1.0.0...main) - -## [v2.1.0.0](https://github.com/freckle/graphula/compare/v2.0.2.2...v2.1.0.0) - -- Some unnecessary `SafeToInsert` have been removed from `node` and `nodeKeyed`. - - `node` only requires `SafeToInsert` when the `KeySource` is `SourceDefault`, - not when the `KeySource` is `KeyArbitrary`. - - `nodeKeyed` no longer ever requires `SafeToInsert` -- `MonadGraphulaFrontend` has a new `insertKeyed` method. - -## [v2.0.2.2](https://github.com/freckle/graphula/compare/v2.0.2.1...v2.0.2.2) - -- Add missing MonadUnliftIO instance to GraphulaLoggedT - -## [v2.0.2.1](https://github.com/freckle/graphula/compare/v2.0.1.1...v2.0.2.1) - -- Support persistent-2.14 - -## [v2.0.1.1](https://github.com/freckle/graphula/compare/v2.0.0.5...v2.0.1.1) - -- Support GHCs 9.0 and 9.2 - -## [v2.0.1.0](https://github.com/freckle/graphula/compare/v2.0.0.5...v2.0.1.0) - -- Add/improve documentation -- Re-organize previously-internal module - -## [v2.0.0.5](https://github.com/freckle/graphula/compare/v2.0.0.4...v2.0.0.5) - -- Release without dependencies upper bounds - -## [v2.0.0.4](https://github.com/freckle/graphula/compare/v2.0.0.3...v2.0.0.4) - -- Relax persistent packages' upper bounds - -## [v2.0.0.3](https://github.com/freckle/graphula/compare/v2.0.0.2...v2.0.0.3) - -- Relax dependencies upper bounds - -## [v2.0.0.2](https://github.com/freckle/graphula/compare/v2.0.0.1...v2.0.0.2) - -- Support GHC-8.10 and unliftio-core 2.0.0 - -## [v2.0.0.1](https://github.com/faktory/graphula/tree/v2.0.0.1) - -First tagged release. +See https://github.com/freckle/graphula/releases diff --git a/graphula.cabal b/graphula.cabal index ac4d798..be2d762 100644 --- a/graphula.cabal +++ b/graphula.cabal @@ -1,11 +1,11 @@ cabal-version: 1.12 --- This file has been generated from package.yaml by hpack version 0.36.0. +-- This file has been generated from package.yaml by hpack version 0.37.0. -- -- see: https://github.com/sol/hpack name: graphula -version: 2.1.0.0 +version: 2.0.0.0 synopsis: A simple interface for generating persistent data and linking its dependencies description: Please see README.md category: Network diff --git a/package.yaml b/package.yaml index 4f2732d..bc4f3b5 100644 --- a/package.yaml +++ b/package.yaml @@ -1,5 +1,5 @@ name: graphula -version: 2.1.0.0 +version: 2.0.0.0 maintainer: Freckle Education category: Network github: freckle/graphula diff --git a/test/README.lhs b/test/README.lhs index aa05326..94b3ce0 100644 --- a/test/README.lhs +++ b/test/README.lhs @@ -209,3 +209,15 @@ runDB f = runSqlite "test.db" $ do f ``` --> + +## Release + +To release a new version of this library, push a commit to `main` using a +conventionally-formatted commit message. + +- Prefix with `fix:` to release a new patch version, +- Prefix with `feat:` to release a new minor version, or +- Prefix with `feat!:` to release a new major version + +To change the "epoch" version, edit it in `package.yaml` and change the +`.releaserc.yaml` tag prefix to match.