diff --git a/.bazelci/presubmit.yml b/.bazelci/presubmit.yml index fab29efc2..8ed5d73ad 100644 --- a/.bazelci/presubmit.yml +++ b/.bazelci/presubmit.yml @@ -1,9 +1,13 @@ --- matrix: + bazel: + - 6.x + - 7.x workdir: [".", "rules_haskell_tests"] tasks: ubuntu1804: + bazel: ${{ bazel }} working_directory: ${{ workdir }} platform: "ubuntu1804" environment: diff --git a/.bcr/presubmit.yml b/.bcr/presubmit.yml index 376812f6d..b4d5ed76e 100644 --- a/.bcr/presubmit.yml +++ b/.bcr/presubmit.yml @@ -9,6 +9,7 @@ matrix: #- windows bazel: - 6.x + - 7.x tasks: verify_targets: name: Verify build targets @@ -31,7 +32,6 @@ tasks: - 'powershell -Command "Invoke-WebRequest -Uri https://hackage.haskell.org/root.json -OutFile out.json"' build_flags: - '--incompatible_enable_cc_toolchain_resolution' - - '--repo_env=BAZEL_USE_CPP_ONLY_TOOLCHAIN=1' build_targets: - '@rules_haskell//haskell/...' - '@rules_haskell//tools/...' diff --git a/.github/ISSUE_TEMPLATE/release.md b/.github/ISSUE_TEMPLATE/release.md index 382a17818..b2a17eaa7 100644 --- a/.github/ISSUE_TEMPLATE/release.md +++ b/.github/ISSUE_TEMPLATE/release.md @@ -23,33 +23,15 @@ about: Steps to work through in order to publish a new release - [ ] Create "Added", "Removed", "Changed" and "Fixed" sections, as necessary. - [ ] If relevant, add links to the corresponding PRs to the entries. -- [ ] Set the revision in [the `start` script][start] and - [`docs/haskell-use-cases`][usecases] to the current release - preparation branch; comment out the checksum. (n.b., Search for - `http_archive` in these files.) - [ ] Update the version of the modules in `MODULE.bazel` files -- [ ] Push the `release-.` branch and open a **draft** PR - to verify CI is green. -- [ ] Create a release tag (`v.`) on the release - preparation branch and push the tag; or use Github's UI. -- [ ] Go to the [release page][releases]: - - [ ] Open the corresponding draft release and copy the workspace snippet. - - [ ] Insert the workspace snippet into [the `start` script][start] - and [`docs/haskell-use-cases`][usecases] replacing the existing snippet. -- [ ] Push the changes to the remote branch and mark the PR as ready; - go through review and merge to `master` upon success. - - If any changes need to be made, upon review, you will need to delete - the release tag (from local and origin) and repeat the previous four - steps appropriately before requesting a follow-up review. - - If there are changes on the release preparation branch that should - *not* go to `master`, create a second branch - `release-.-master` on `master` and cherry-pick all - relevant commits from the release branch preparation branch. Open a - pull request with that branch, go through review and push changes - back to the release preparation branch. -- [ ] Go to the [release page][releases]: - - [ ] Open the draft release for the current version. - - [ ] Release. +- [ ] Push the `release-.` branch and open a PR; go through review and merge upon success. +- [ ] Trigger the `Prepare Release` workflow + - either via the Github UI **or** + - run `gh workflow run -f version=. 'Prepare Release'` using the Github CLI +- [ ] Go to the [releases], open the draft release which was created to inspect it + - Do the code snippets look valid? + - Is there a release artifact attached to it? + - If you're happy, publish the release... :rocket: - [ ] After the "Publish" workflow is finished check whether https://haskell.build/start is now the latest [`start` script][start] (Netlify sometimes has problems). - [ ] Announce the new version on Twitter by asking someone with access. diff --git a/.github/workflows/prepare-release.yaml b/.github/workflows/prepare-release.yaml index fd68c7dcd..d308ddffa 100644 --- a/.github/workflows/prepare-release.yaml +++ b/.github/workflows/prepare-release.yaml @@ -1,38 +1,51 @@ -name: Prepare release +# Create a draft release when triggered via Github's UI or Github CLI +name: Prepare Release on: - push: - tags: - - "v[0-9]*.[0-9]*" + workflow_dispatch: + inputs: + version: + description: 'Version to release (e.g. 0.11.0)' + required: true + type: string + +permissions: + contents: write jobs: - update-release-notes: - name: Update release + release: + name: Prepare Release runs-on: ubuntu-latest steps: + - name: Check version + run: | + if ! [[ '${{ inputs.version }}' =~ ^[0-9]+[.][0-9]+([.][0-9]+)?$ ]]; then + echo '${{ inputs.version }} does not match expected format `major.minor.patch?`' >&2 + exit 1 + fi - name: Checkout uses: actions/checkout@v4 - - name: Create archive - id: archive + with: + ref: master # only create releases from main branch + - name: Read section from CHANGELOG.md + id: extract-changelog + uses: sean0x42/markdown-extract@v2 + with: + file: CHANGELOG.md + pattern: ${{ inputs.version }} + - name: Prepare release notes and artifacts run: | - TAG="${GITHUB_REF_NAME}" - REPOSITORY_NAME="${GITHUB_REPOSITORY#*/}" - PREFIX="${REPOSITORY_NAME}-${TAG:1}" - ARCHIVE="${PREFIX}.tar.gz" - - echo "tgz=${ARCHIVE}" >> $GITHUB_OUTPUT - - git archive --format=tar.gz --prefix="${PREFIX}/" -o "$ARCHIVE" "${TAG}" - - name: Prepare bzlmod / WORKSPACE snippets - run: .github/workflows/prepare_snippets.sh ${{ steps.archive.outputs.tgz }} > release_notes.txt - - name: Generate changelog + .github/workflows/release_prep.sh v${{ inputs.version }} > release_notes.txt + printf '${{ steps.extract-changelog.outputs.markdown }}' >> release_notes.txt + - name: Create draft release + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | - printf '\n-----\n\n' >> release_notes.txt - awk -f .github/workflows/changelog.awk CHANGELOG.md >> release_notes.txt - - name: Release - uses: softprops/action-gh-release@v2 - with: - draft: true - body_path: release_notes.txt - fail_on_unmatched_files: true - files: ${{ steps.archive.outputs.tgz }} + gh release create \ + --draft \ + --notes-file release_notes.txt \ + --title v${{ inputs.version }} \ + v${{ inputs.version }} \ + ${GITHUB_REPOSITORY#*/}-${{ inputs.version }}.tar.gz | tee release_url + - name: Write summary + run: 'echo ":rocket: Draft release created [here]($( cat release_url ))" >> "${GITHUB_STEP_SUMMARY}"' diff --git a/.github/workflows/prepare_snippets.sh b/.github/workflows/prepare_snippets.sh deleted file mode 100755 index f90753060..000000000 --- a/.github/workflows/prepare_snippets.sh +++ /dev/null @@ -1,40 +0,0 @@ -#!/usr/bin/env bash - -set -o errexit -o nounset -o pipefail - -ARCHIVE="$1" - -# Set by GH actions, see -# https://docs.github.com/en/actions/learn-github-actions/environment-variables#default-environment-variables -TAG=${GITHUB_REF_NAME} -REPO_NAME=${GITHUB_REPOSITORY#*/} -PREFIX="${REPO_NAME}-${TAG:1}" -URL="https://github.com/${GITHUB_REPOSITORY}/releases/download/$TAG/$ARCHIVE" - -if ! SHA=$( shasum -a 256 "$ARCHIVE" | awk '{print $1}'); then - echo "error: could not determine hash for ${ARCHIVE}" >&2 - exit 1 -fi - -cat << EOF -## Using bzlmod with Bazel 6 - -1. Enable with \`common --enable_bzlmod\` in \`.bazelrc\`. -2. Add to your \`MODULE.bazel\` file: - -\`\`\`starlark -bazel_dep(name = "rules_haskell", version = "${TAG:1}") -\`\`\` - -## Using WORKSPACE - -\`\`\`starlark -load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") -http_archive( - name = "${REPO_NAME}", - sha256 = "${SHA}", - strip_prefix = "${PREFIX}", - url = "${URL}", -) -\`\`\` -EOF diff --git a/.github/workflows/publish.yaml b/.github/workflows/publish.yaml index 5ae69a648..d48991e1e 100644 --- a/.github/workflows/publish.yaml +++ b/.github/workflows/publish.yaml @@ -2,7 +2,7 @@ name: Publish on: release: - types: [published] + types: [released] workflow_dispatch: # allows manual triggering jobs: @@ -21,5 +21,30 @@ jobs: git config user.email github-actions@github.com - name: Merge master into release run: git merge --no-edit origin/master - - name: Push - run: git push + - name: Fetch latest release artifact + id: latest + env: + GH_TOKEN: ${{ github.token }} + run: | + gh release download -p '*.tar.gz' -D release + ls release | sed -ne 's/rules_haskell-\(.*\)[.]tar[.]gz/version=\1/p' >> "${GITHUB_OUTPUT}" + shasum -a 256 release/*.tar.gz | awk '{print "hash=" $1}' >> "${GITHUB_OUTPUT}" + - name: Update hash in start script and docs + run: | + sed -i \ + -e '/bazel_dep(name = "rules_haskell"/s/version = "[^"]*"/version = "${{ steps.latest.outputs.version }}"/' \ + start + # update http_archive attrs between `name = "rules_haskell"` and `url = "` + sed -i \ + -e '/name = "rules_haskell"/,/url = "/{' \ + -e ' s%x\{64\}%${{ steps.latest.outputs.hash }}%; ' \ + -e ' s%M[.]NN%${{ steps.latest.outputs.version }}%g ' \ + -e '}' \ + start docs/haskell-use-cases.rst + - name: Commit and Push + run: | + if ! git diff --exit-code ; then + git add start docs/haskell-use-cases.rst + git commit -m "Update rules_haskell in start script and docs to version ${{ steps.latest.outputs.version }}" + git push + fi diff --git a/.github/workflows/release_prep.sh b/.github/workflows/release_prep.sh new file mode 100755 index 000000000..e51a2c9f1 --- /dev/null +++ b/.github/workflows/release_prep.sh @@ -0,0 +1,40 @@ +#!/usr/bin/env bash +set -euo pipefail + +TAG=$1 +REPO_NAME=${GITHUB_REPOSITORY#*/} +# The prefix is chosen to match what GitHub generates for source archives +PREFIX="${REPO_NAME}-${TAG:1}" +ARCHIVE="${REPO_NAME}-${TAG:1}.tar.gz" +git archive --format=tar.gz --prefix="${PREFIX}/" -o $ARCHIVE HEAD +SHA=$(shasum -a 256 "$ARCHIVE" | awk '{print $1}') + +cat << EOF +## Using Bzlmod with Bazel 6+ + +1. Enable with \`common --enable_bzlmod\` in \`.bazelrc\`. +2. Add to your \`MODULE.bazel\` file: + +\`\`\`starlark +bazel_dep(name = "${REPO_NAME}", version = "${TAG:1}") +\`\`\` + +## Using WORKSPACE + +Paste this snippet into your \`WORKSPACE.bazel\` file: + +\`\`\`starlark +load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") + +http_archive( + name = "${REPO_NAME}", + sha256 = "${SHA}", + strip_prefix = "$PREFIX", + urls = ["https://github.com/$GITHUB_REPOSITORY/releases/download/$TAG/$ARCHIVE"], +) + +load("@${REPO_NAME}//haskell:repositories.bzl", "${REPO_NAME}_dependencies") + +${REPO_NAME}_dependencies() +\`\`\` +EOF diff --git a/CHANGELOG.md b/CHANGELOG.md index bc612e838..af10a27f2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,14 +3,41 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/). -## Next release + +## [1.0] 2024-09-23 + +[1.0]: https://github.com/tweag/rules_haskell/compare/v0.19...v1.0 + +### Highlights + +* Support for Bazel 7 (see https://github.com/tweag/rules_haskell/pull/2232) +* Support for GHC 9.8.x (see https://github.com/tweag/rules_haskell/pull/2132) + +### Added + +* Support for unit-based hie-bios script for ghc 9.4+ (See https://github.com/tweag/rules_haskell/pull/2218) +* Preliminary support for GHC 9.10.x (See https://github.com/tweag/rules_haskell/pull/2198) + +### Fixed + +* Handle RTS library for GHC 9.4+ (See https://github.com/tweag/rules_haskell/pull/2202) +* Error when building cabal sub-libraries (See https://github.com/tweag/rules_haskell/pull/2135) ### Changed * Use ghc 9.4.6 by default * Use Bazel 6.5.0 by default (See https://github.com/tweag/rules_haskell/pull/2117) +* Update nixpkgs revision to nixos-24.05, + **note***: requires rules\_nixpkgs version >= 0.12 (See https://github.com/tweag/rules_haskell/pull/2217) +* Asterius is deprecated and not tested anymore (See https://github.com/tweag/rules_haskell/pull/2182) +* No longer create empty libraries (See https://github.com/tweag/rules_haskell/pull/2158) +* Make static linking of haskell_cabal_binary explicit (See https://github.com/tweag/rules_haskell/pull/2148) + +### Removed + +* Testing GHC 9.2.x on CI -## [0.19] 2024-02-5 +## [0.19] 2024-02-07 [0.19]: https://github.com/tweag/rules_haskell/compare/v0.18...v0.19 diff --git a/MODULE.bazel b/MODULE.bazel index dc5ee7b00..8dba7014a 100644 --- a/MODULE.bazel +++ b/MODULE.bazel @@ -1,6 +1,6 @@ module( name = "rules_haskell", - version = "0.19", + version = "1.0", ) bazel_dep( diff --git a/docs/haskell-use-cases.rst b/docs/haskell-use-cases.rst index cd32a25b4..4f50bc01a 100644 --- a/docs/haskell-use-cases.rst +++ b/docs/haskell-use-cases.rst @@ -28,9 +28,9 @@ rules_haskell. To use a released version, do the following:: http_archive( name = "rules_haskell", - sha256 = "34742848a8882d94a0437b3b1917dea6f58c82fe5762afe8d249d3a36e51935d", - strip_prefix = "rules_haskell-0.19", - url = "https://github.com/tweag/rules_haskell/releases/download/v0.19/rules_haskell-0.19.tar.gz", + sha256 = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx", + strip_prefix = "rules_haskell-M.NN", + url = "https://github.com/tweag/rules_haskell/releases/download/vM.NN/rules_haskell-M.NN.tar.gz", ) Picking a compiler diff --git a/examples/MODULE.bazel b/examples/MODULE.bazel index 80e5252ae..9236e1ccf 100644 --- a/examples/MODULE.bazel +++ b/examples/MODULE.bazel @@ -9,11 +9,11 @@ bazel_dep( ) bazel_dep( name = "rules_haskell_nix", - version = "0.19", + version = "1.0", ) bazel_dep( name = "rules_haskell", - version = "0.19", + version = "1.0", ) # TODO diff --git a/registry/modules/rules_haskell/0.19/MODULE.bazel b/registry/modules/rules_haskell/1.0/MODULE.bazel similarity index 100% rename from registry/modules/rules_haskell/0.19/MODULE.bazel rename to registry/modules/rules_haskell/1.0/MODULE.bazel diff --git a/registry/modules/rules_haskell/0.19/source.json b/registry/modules/rules_haskell/1.0/source.json similarity index 100% rename from registry/modules/rules_haskell/0.19/source.json rename to registry/modules/rules_haskell/1.0/source.json diff --git a/registry/modules/rules_haskell/metadata.json b/registry/modules/rules_haskell/metadata.json index 8500a5c7c..937cc6592 100644 --- a/registry/modules/rules_haskell/metadata.json +++ b/registry/modules/rules_haskell/metadata.json @@ -1,6 +1,6 @@ { "homepage": "", "maintainers": [], - "versions": ["0.19"], + "versions": ["1.0"], "yanked_versions": [] } diff --git a/registry/modules/rules_haskell_nix/0.19/MODULE.bazel b/registry/modules/rules_haskell_nix/1.0/MODULE.bazel similarity index 100% rename from registry/modules/rules_haskell_nix/0.19/MODULE.bazel rename to registry/modules/rules_haskell_nix/1.0/MODULE.bazel diff --git a/registry/modules/rules_haskell_nix/0.19/source.json b/registry/modules/rules_haskell_nix/1.0/source.json similarity index 100% rename from registry/modules/rules_haskell_nix/0.19/source.json rename to registry/modules/rules_haskell_nix/1.0/source.json diff --git a/registry/modules/rules_haskell_nix/metadata.json b/registry/modules/rules_haskell_nix/metadata.json index 8500a5c7c..937cc6592 100644 --- a/registry/modules/rules_haskell_nix/metadata.json +++ b/registry/modules/rules_haskell_nix/metadata.json @@ -1,6 +1,6 @@ { "homepage": "", "maintainers": [], - "versions": ["0.19"], + "versions": ["1.0"], "yanked_versions": [] } diff --git a/rules_haskell_nix/MODULE.bazel b/rules_haskell_nix/MODULE.bazel index ad904637e..d2d3d93b2 100644 --- a/rules_haskell_nix/MODULE.bazel +++ b/rules_haskell_nix/MODULE.bazel @@ -1,11 +1,11 @@ module( name = "rules_haskell_nix", - version = "0.19", + version = "1.0", ) bazel_dep( name = "rules_haskell", - version = "0.19", + version = "1.0", ) bazel_dep( name = "rules_sh", diff --git a/rules_haskell_tests/MODULE.bazel b/rules_haskell_tests/MODULE.bazel index c136ba33a..923454484 100644 --- a/rules_haskell_tests/MODULE.bazel +++ b/rules_haskell_tests/MODULE.bazel @@ -1,6 +1,6 @@ module( name = "rules_haskell_tests", - version = "0.19", + version = "1.0", ) bazel_dep( @@ -9,11 +9,11 @@ bazel_dep( ) bazel_dep( name = "rules_haskell_nix", - version = "0.19", + version = "1.0", ) bazel_dep( name = "rules_haskell", - version = "0.19", + version = "1.0", ) bazel_dep( name = "rules_license", diff --git a/rules_haskell_tests/tests/bzlmod_runfiles/other_module/MODULE.bazel b/rules_haskell_tests/tests/bzlmod_runfiles/other_module/MODULE.bazel index 66d8a325b..6147a7a7c 100644 --- a/rules_haskell_tests/tests/bzlmod_runfiles/other_module/MODULE.bazel +++ b/rules_haskell_tests/tests/bzlmod_runfiles/other_module/MODULE.bazel @@ -5,11 +5,11 @@ module( bazel_dep( name = "rules_haskell_nix", - version = "0.19", + version = "1.0", ) bazel_dep( name = "rules_haskell", - version = "0.19", + version = "1.0", ) bazel_dep( name = "rules_nixpkgs_core", diff --git a/start b/start index e56ae1224..d28823f31 100755 --- a/start +++ b/start @@ -251,9 +251,9 @@ load( # Download rules_haskell and make it accessible as "@rules_haskell". http_archive( name = "rules_haskell", - sha256 = "34742848a8882d94a0437b3b1917dea6f58c82fe5762afe8d249d3a36e51935d", - strip_prefix = "rules_haskell-0.19", - url = "https://github.com/tweag/rules_haskell/releases/download/v0.19/rules_haskell-0.19.tar.gz", + sha256 = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx", + strip_prefix = "rules_haskell-M.NN", + url = "https://github.com/tweag/rules_haskell/releases/download/vM.NN/rules_haskell-M.NN.tar.gz", ) load( @@ -376,7 +376,7 @@ if $BZLMOD; then cat >MODULE.bazel <