From 56d63b3b84d5b67e2ed06aa1c65ab390afcdb457 Mon Sep 17 00:00:00 2001 From: Rin Kuryloski Date: Wed, 16 Aug 2023 08:50:22 +0200 Subject: [PATCH] Add a release workflow for publishing to bazel-central-registry To publish a release: 1. Tag a commit matching the v2.* pattern 2. Review and publish the draft github release created by the workflow --- .bcr/config.yml | 0 .bcr/metadata.template.json | 20 ++++++++++++++ .bcr/presubmit.yml | 27 +++++++++++++++++++ .bcr/source.template.json | 5 ++++ .github/workflows/release.yml | 51 +++++++++++++++++++++++++++++++++++ MODULE.bazel | 8 +++--- WORKSPACE.bazel | 2 ++ 7 files changed, 109 insertions(+), 4 deletions(-) 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/release.yml diff --git a/.bcr/config.yml b/.bcr/config.yml new file mode 100644 index 00000000..e69de29b diff --git a/.bcr/metadata.template.json b/.bcr/metadata.template.json new file mode 100644 index 00000000..3664dd1d --- /dev/null +++ b/.bcr/metadata.template.json @@ -0,0 +1,20 @@ +{ + "homepage": "https://github.com/rabbitmq/ra", + "maintainers": [ + { + "email": "nkarl@vmware.com", + "github": "kjnilsson", + "name": "Karl Nilsson" + }, + { + "email": "kuryloskip@vmware.com", + "github": "pjk25", + "name": "Rin Kuryloski" + } + ], + "repository": [ + "github:rabbitmq/ra" + ], + "versions": [], + "yanked_versions": {} +} diff --git a/.bcr/presubmit.yml b/.bcr/presubmit.yml new file mode 100644 index 00000000..62faa2b5 --- /dev/null +++ b/.bcr/presubmit.yml @@ -0,0 +1,27 @@ +shell_commands: &shell_commands +- curl -O https://raw.githubusercontent.com/kerl/kerl/master/kerl +- chmod a+x kerl +- ./kerl update releases +- ./kerl build ${ERLANG_VERSION} +- ./kerl install ${ERLANG_VERSION} ~/kerl/${ERLANG_VERSION} +- realpath ~/kerl/${ERLANG_VERSION} + +platforms: + macos: + environment: + ERLANG_VERSION: "25.0" + ERLANG_HOME: /Users/buildkite/kerl/25.0 + shell_commands: *shell_commands + build_flags: + - --incompatible_strict_action_env + build_targets: + - '@rabbitmq_ra//:erlang_app' + ubuntu2004: + environment: + ERLANG_VERSION: "25.0" + ERLANG_HOME: /var/lib/buildkite-agent/kerl/25.0 + shell_commands: *shell_commands + build_flags: + - --incompatible_strict_action_env + build_targets: + - '@rabbitmq_ra//:erlang_app' diff --git a/.bcr/source.template.json b/.bcr/source.template.json new file mode 100644 index 00000000..ea011e71 --- /dev/null +++ b/.bcr/source.template.json @@ -0,0 +1,5 @@ +{ + "integrity": "", + "strip_prefix": "{REPO}-{VERSION}", + "url": "https://github.com/{OWNER}/{REPO}/releases/download/{TAG}/ra-{VERSION}.tar.gz" +} diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 00000000..2d58e313 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,51 @@ +name: Release +on: + push: + tags: + - v2.* +jobs: + release: + runs-on: ubuntu-latest + steps: + - name: CHECKOUT + uses: actions/checkout@v3 + with: + path: ra + - name: ASSERT VERSIONS + id: versions + working-directory: ra + run: | + sudo npm install --global --silent @bazel/buildozer + + VERSION_APP_SRC="$(erl -eval '{ok, [{application, _, AppInfo}]} = file:consult("src/ra.app.src"), Version = proplists:get_value(vsn, AppInfo), io:fwrite(Version), halt().' -noshell)" + + if [[ "${{ github.ref_name }}" != "v$VERSION_APP_SRC" ]]; then + echo "Version in src/ra.app.src ($VERSION_APP_SRC) does not match tag (${{ github.ref_name }})" + exit 1 + fi + + VERSION_BAZEL="$(cat MODULE.bazel | buildozer 'print version' -:%module)" + + if [[ "${{ github.ref_name }}" != "v$VERSION_BAZEL" ]]; then + echo "Version in MODULE.bazel ($VERSION_BAZEL) does not match tag (${{ github.ref_name }})" + exit 1 + fi + + echo "version=$VERSION_BAZEL" | tee -a $GITHUB_OUTPUT + - name: FETCH THE SOURCE ARCHIVE + run: | + curl \ + -L \ + -o ra-${{ steps.versions.outputs.version }}.tar.gz \ + https://github.com/${{ github.repository }}/archive/${{ github.ref }}.tar.gz + - name: CREATE RELEASE + id: create-release + uses: ncipollo/release-action@v1.12.0 + with: + allowUpdates: true + draft: true + artifactErrorsFailBuild: true + updateOnlyUnreleased: true + generateReleaseNotes: true + artifacts: >- + ra-${{ steps.versions.outputs.version }}.tar.gz diff --git a/MODULE.bazel b/MODULE.bazel index 184d5269..dc7e2f2e 100644 --- a/MODULE.bazel +++ b/MODULE.bazel @@ -1,11 +1,11 @@ module( - name = "ra", - version = "2.4.0", + name = "rabbitmq_ra", + version = "2.6.3", ) bazel_dep( name = "rules_erlang", - version = "3.10.5", + version = "3.11.4", ) erlang_config = use_extension( @@ -94,7 +94,7 @@ erlang_dev_package = use_extension( erlang_package.hex_package( name = "eunit_formatters", version = "0.5.0", - build_file = "@ra//bzl:BUILD.eunit_formatters", + build_file = "@rabbitmq_ra//bzl:BUILD.eunit_formatters", ) use_repo( diff --git a/WORKSPACE.bazel b/WORKSPACE.bazel index 51fb71dc..3bad5fdd 100644 --- a/WORKSPACE.bazel +++ b/WORKSPACE.bazel @@ -1,3 +1,5 @@ +workspace(name = "rabbitmq_ra") + load( "@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive",