From 87476a962e708a321176694c973fb3baafdd61e3 Mon Sep 17 00:00:00 2001 From: Manuel Naranjo Date: Wed, 28 Aug 2024 08:30:28 +0200 Subject: [PATCH] release: prepare release process Started adding a release propecess to our repositority --- .gitattributes | 8 ++++ .github/workflows/release.yml | 29 ++++++++++++ .github/workflows/release_prep.sh | 75 +++++++++++++++++++++++++++++++ 3 files changed, 112 insertions(+) create mode 100644 .gitattributes create mode 100644 .github/workflows/release.yml create mode 100644 .github/workflows/release_prep.sh diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..2439a10 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,8 @@ +# Configuration for 'git archive' +# see https://git-scm.com/docs/git-archive/2.40.0#ATTRIBUTES +# Exclude a bunch of paths to save some disk space +e2e export-ignore +.aspect export-ignore +.github export-ignore +dev export-ignore +remap_tar_test export-ignore diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..7e14295 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,29 @@ +# Cut a release whenever a new tag is pushed to the repo. +# You should use an annotated tag, like `git tag -a v1.2.3` +# and put the release notes into the commit message for the tag. +name: Release + +on: + push: + tags: + - "v*.*.*" + +jobs: + release: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - name: Prepare release + run: .github/workflows/release_prep.sh > release_notes.txt + + - name: Release + uses: softprops/action-gh-release@v1 + with: + prerelease: true + # Use GH feature to populate the changelog automatically + generate_release_notes: true + body_path: release_notes.txt + files: | + rules_booking-*.tar.gz + fail_on_unmatched_files: true diff --git a/.github/workflows/release_prep.sh b/.github/workflows/release_prep.sh new file mode 100644 index 0000000..d1aab0f --- /dev/null +++ b/.github/workflows/release_prep.sh @@ -0,0 +1,75 @@ +#!/usr/bin/env bash + +set -o errexit -o nounset -o pipefail +set -x + +SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) + +# Set by GH actions, see +# https://docs.github.com/en/actions/learn-github-actions/environment-variables#default-environment-variables + +# The prefix is chosen to match what GitHub generates for source archives +PREFIX="rules_booking-${GITHUB_REF_NAME}" +ARCHIVE="${PREFIX}.tar.gz" +ARCHIVE_TMP=$(mktemp) + +# NB: configuration for 'git archive' is in /.gitattributes +git archive --format=tar --prefix=${PREFIX}/ --worktree-attributes ${GITHUB_REF_NAME} > $ARCHIVE_TMP + +# we could patch the tar here if we needed binaries + +gzip < $ARCHIVE_TMP > $ARCHIVE +SHA=$(shasum -a 256 $ARCHIVE | awk '{print $1}') +INTEGRITY=$(openssl dgst -sha256 -binary $ARCHIVE | openssl base64 -A | sed 's/^/sha256-/') + +# Set by GH actions, see +# https://docs.github.com/en/actions/learn-github-actions/environment-variables#default-environment-variables +REPO_URL="https://github.com/${GITHUB_REPOSITORY:-bookingcom/rules_booking}" + +cat << EOF +## Using [Bzlmod] with Bazel 6: + +Add to your \`MODULE.bazel\` file: + +\`\`\`starlark +bazel_dep(name = "rules_booking", version = "${GITHUB_REF_NAME:1}") + +archive_override( + module_name = "rules_booking", + integrity = "${INTEGRITY}", + urls = [ + "${REPO_URL}/releases/download/${GITHUB_REF_NAME}/${ARCHIVE}", + ] +) + +\`\`\` + +[Bzlmod]: https://bazel.build/build/bzlmod + +## Using WORKSPACE + +\`\`\`starlark +load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") +http_archive( + name = "rules_booking", + sha256 = "${SHA}", + strip_prefix = "${PREFIX}", + url = "${REPO_URL}/releases/download/${GITHUB_REF_NAME}/${ARCHIVE}", +) + +load( + "@rules_booking//:repositories.bzl", + rules_booking_repositories = "repositories", +) + +rules_booking_repositories() + +load( + "@rules_booking//:dependencies.bzl", + rules_booking_dependencies = "dependencies", +) + +rules_booking_dependencies() + +\`\`\` +EOF