From 5939e094a123027a9693ff47fec2e926cd9b86fd Mon Sep 17 00:00:00 2001 From: Richard Levasseur Date: Wed, 27 Nov 2024 13:55:33 -0800 Subject: [PATCH] chore: setup a github action to create releases --- .bcr/config.yml | 3 + .bcr/metadata.template.json | 20 ++++ .bcr/presubmit.yml | 15 +++ .bcr/source.template.json | 5 + .github/workflows/create_archive_and_notes.sh | 101 ++++++++++++++++++ .github/workflows/release.yml | 41 +++++++ 6 files changed, 185 insertions(+) create mode 100644 .bcr/config.yml create mode 100644 .bcr/metadata.template.json create mode 100644 .bcr/presubmit.yml create mode 100644 .bcr/source.template.json create mode 100644 .github/workflows/create_archive_and_notes.sh create mode 100644 .github/workflows/release.yml diff --git a/.bcr/config.yml b/.bcr/config.yml new file mode 100644 index 0000000..018b1de --- /dev/null +++ b/.bcr/config.yml @@ -0,0 +1,3 @@ +fixedReleaser: + login: tetromino + email: arostovtsev@google.com diff --git a/.bcr/metadata.template.json b/.bcr/metadata.template.json new file mode 100644 index 0000000..5a958a9 --- /dev/null +++ b/.bcr/metadata.template.json @@ -0,0 +1,20 @@ +{ + "homepage": "https://github.com/bazelbuild/stardoc", + "maintainers": [ + { + "name": "Alexandre Rostovtsev", + "email": "arostovtsev@google.com", + "github": "tetromino" + }, + { + "name": "Jon Brandvein", + "email": "brandjon@google.com", + "github": "brandjon" + } + ], + "repository": [ + "github:bazelbuild/stardoc" + ], + "versions": [], + "yanked_versions": {} +} diff --git a/.bcr/presubmit.yml b/.bcr/presubmit.yml new file mode 100644 index 0000000..49d29f3 --- /dev/null +++ b/.bcr/presubmit.yml @@ -0,0 +1,15 @@ +matrix: + platform: + - debian10 + - ubuntu2004 + - macos + - windows + bazel: + - 7.x +tasks: + verify_targets: + name: Verify build targets + platform: ${{ platform }} + bazel: ${{ bazel }} + build_targets: + - '@stardoc//stardoc/...' diff --git a/.bcr/source.template.json b/.bcr/source.template.json new file mode 100644 index 0000000..7fb5985 --- /dev/null +++ b/.bcr/source.template.json @@ -0,0 +1,5 @@ +{ + "integrity": "**leave this alone**", + "strip_prefix": "{REPO}-{VERSION}", + "url": "https://github.com/{OWNER}/{REPO}/releases/download/{TAG}/{REPO}-{TAG}.tar.gz" +} diff --git a/.github/workflows/create_archive_and_notes.sh b/.github/workflows/create_archive_and_notes.sh new file mode 100644 index 0000000..6a02227 --- /dev/null +++ b/.github/workflows/create_archive_and_notes.sh @@ -0,0 +1,101 @@ +#!/usr/bin/env bash +# Copyright 2023 The Bazel Authors. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +set -o errexit -o nounset -o pipefail + +# Set by GH actions, see +# https://docs.github.com/en/actions/learn-github-actions/environment-variables#default-environment-variables +TAG=${GITHUB_REF_NAME} +# A prefix is added to better match the GitHub generated archives. +PREFIX="stardoc-${TAG}" +ARCHIVE="stardoc-$TAG.tar.gz" + +bazel build //distro:distro +# Copy it locally so release.yml sees it +cp bazel-bin/distro/stardoc-*.tar.gz $ARCHIVE + +SHA=$(shasum -a 256 $ARCHIVE | awk '{print $1}') + +cat > release_notes.txt << EOF + +## MODULE.bazel setup + +Add to your \`MODULE.bazel\` file: + +\`\`\`starlark +bazel_dep(name = "stardoc", version = "${TAG}") +\`\`\` + +By default - in other words, when using Bzlmod for dependency management - +Stardoc uses @stardoc as its repo name. The legacy WORSKSPACE setup (see below) +used @io_bazel_stardoc instead. For compatibility with the legacy WORKSPACE +setup, you may add repo_name = "io_bazel_stardoc" to the bazel_dep call. + +## Legacy WORKSPACE setup + +To use Stardoc, add the following to your WORKSPACE file: + +\`\`\`starlark +load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") + +http_archive( + name = "io_bazel_stardoc", + sha256 = "${SHA}", + strip_prefix = "${PREFIX}", + url = "https://github.com/bazelbuild/stardoc/releases/download/${TAG}/stardoc-${TAG}.tar.gz", +) + +load("@io_bazel_stardoc//:setup.bzl", "stardoc_repositories") + +stardoc_repositories() + +load("@rules_java//java:rules_java_deps.bzl", "rules_java_dependencies") + +rules_java_dependencies() + +load("@com_google_protobuf//:protobuf_deps.bzl", "protobuf_deps") + +protobuf_deps() + +load("@rules_jvm_external//:repositories.bzl", "rules_jvm_external_deps") + +rules_jvm_external_deps() + +load("@rules_jvm_external//:setup.bzl", "rules_jvm_external_setup") + +rules_jvm_external_setup() + +load("@io_bazel_stardoc//:deps.bzl", "stardoc_external_deps") + +stardoc_external_deps() + +load("@stardoc_maven//:defs.bzl", stardoc_pinned_maven_install = "pinned_maven_install") + +stardoc_pinned_maven_install() + +\`\`\` + +The sequence of function calls and load statements after the io_bazel_stardoc +repository definition ensures that this repository's dependencies are loaded +(each function call defines additional repositories for Stardoc's dependencies, +which are then used by subsequent load statements). + +Note that WORKSPACE files are sensitive to the order of dependencies. If, after +updating to a newer version of Stardoc, you encounter "not a valid +maven_install.json file" or other repository fetch errors (example: #186), try +moving the Stardoc dependency block above or below other dependencies in your +WORKSPACE file. + +EOF diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..8b40be2 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,41 @@ +# Copyright 2024 The Bazel Authors. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Cut a release whenever a new tag is pushed to the repo. +name: Release + +on: + push: + tags: + - "*.*.*" + +jobs: + build: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + - name: Setup Bazel + uses: bazel-contrib/setup-bazel@0.9.1 + - name: Create release archive and notes + run: .github/workflows/create_archive_and_notes.sh + - name: Release + uses: softprops/action-gh-release@v2 + with: + # Use GH feature to populate the changelog automatically + generate_release_notes: true + body_path: release_notes.txt + fail_on_unmatched_files: true + files: stardoc-*.tar.gz +