Skip to content

Commit

Permalink
Merge pull request #2248 from tweag/cb/prepare-release
Browse files Browse the repository at this point in the history
Prepare release 1.0 🚀
  • Loading branch information
avdv authored Sep 23, 2024
2 parents ad698b6 + 5f64603 commit a361943
Show file tree
Hide file tree
Showing 22 changed files with 172 additions and 121 deletions.
4 changes: 4 additions & 0 deletions .bazelci/presubmit.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
---
matrix:
bazel:
- 6.x
- 7.x
workdir: [".", "rules_haskell_tests"]

tasks:
ubuntu1804:
bazel: ${{ bazel }}
working_directory: ${{ workdir }}
platform: "ubuntu1804"
environment:
Expand Down
2 changes: 1 addition & 1 deletion .bcr/presubmit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ matrix:
#- windows
bazel:
- 6.x
- 7.x
tasks:
verify_targets:
name: Verify build targets
Expand All @@ -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/...'
34 changes: 8 additions & 26 deletions .github/ISSUE_TEMPLATE/release.md
Original file line number Diff line number Diff line change
Expand Up @@ -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-<major>.<minor>` branch and open a **draft** PR
to verify CI is green.
- [ ] Create a release tag (`v<major>.<minor>`) 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-<major>.<minor>-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-<major>.<minor>` 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=<major>.<minor> '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.
Expand Down
69 changes: 41 additions & 28 deletions .github/workflows/prepare-release.yaml
Original file line number Diff line number Diff line change
@@ -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}"'
40 changes: 0 additions & 40 deletions .github/workflows/prepare_snippets.sh

This file was deleted.

31 changes: 28 additions & 3 deletions .github/workflows/publish.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: Publish

on:
release:
types: [published]
types: [released]
workflow_dispatch: # allows manual triggering

jobs:
Expand All @@ -21,5 +21,30 @@ jobs:
git config user.email [email protected]
- 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
40 changes: 40 additions & 0 deletions .github/workflows/release_prep.sh
Original file line number Diff line number Diff line change
@@ -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
31 changes: 29 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion MODULE.bazel
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module(
name = "rules_haskell",
version = "0.19",
version = "1.0",
)

bazel_dep(
Expand Down
6 changes: 3 additions & 3 deletions docs/haskell-use-cases.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions examples/MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion registry/modules/rules_haskell/metadata.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"homepage": "",
"maintainers": [],
"versions": ["0.19"],
"versions": ["1.0"],
"yanked_versions": []
}
2 changes: 1 addition & 1 deletion registry/modules/rules_haskell_nix/metadata.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"homepage": "",
"maintainers": [],
"versions": ["0.19"],
"versions": ["1.0"],
"yanked_versions": []
}
4 changes: 2 additions & 2 deletions rules_haskell_nix/MODULE.bazel
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
Loading

0 comments on commit a361943

Please sign in to comment.