From 85b2d942953bf6907028680d15dff4426821a49a Mon Sep 17 00:00:00 2001 From: Rin Kuryloski Date: Thu, 7 Sep 2023 10:50:31 +0200 Subject: [PATCH] Add automation to publish to our bzlmod registry on release --- .github/workflows/publish-rabbitmq-bcr.yml | 76 ++++++++++++++++++++++ .github/workflows/release.yml | 1 - 2 files changed, 76 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/publish-rabbitmq-bcr.yml diff --git a/.github/workflows/publish-rabbitmq-bcr.yml b/.github/workflows/publish-rabbitmq-bcr.yml new file mode 100644 index 00000000..373b0f55 --- /dev/null +++ b/.github/workflows/publish-rabbitmq-bcr.yml @@ -0,0 +1,76 @@ +name: Add to rabbitmq/bazel-central-registry@erlang-packages +on: + release: + types: [published] + workflow_dispatch: +jobs: + add-module: + runs-on: ubuntu-latest + steps: + - name: CHECKOUT + uses: actions/checkout@v3 + with: + path: ra + - name: CHECKOUT rabbitmq/bazel-central-registry@erlang-packages + uses: actions/checkout@v3 + with: + repository: rabbitmq/bazel-central-registry + path: bazel-central-registry + ref: erlang-packages + - name: PUBLISH TO rabbitmq/bazel-central-registry@erlang-packages + working-directory: bazel-central-registry + env: + MODULE_NAME: rabbitmq_ra + REPO_NAME: ra + run: | + VERSION="${{ github.ref_name }}" + VERSION="${VERSION#v}" + MAJOR="${VERSION:0:1}" + + echo "VERSION: ${VERSION}" + echo "MAJOR: ${MAJOR}" + + cat << EOF > ${MODULE_NAME}.json + { + "build_file": null, + "build_targets": [ + "@${MODULE_NAME}//:${MODULE_NAME}", + "@${MODULE_NAME}//:erlang_app" + ], + "compatibility_level": "$((${MAJOR} - 1))", + "deps": [], + "module_dot_bazel": "${{ github.workspace }}/${REPO_NAME}/MODULE.bazel", + "name": "${MODULE_NAME}", + "patch_strip": 0, + "patches": [], + "presubmit_yml": "${{ github.workspace }}/${REPO_NAME}/.bcr/presubmit.yml", + "strip_prefix": "${REPO_NAME}-${VERSION}", + "test_module_build_targets": [], + "test_module_path": null, + "test_module_test_targets": [], + "url": "https://github.com/${{ github.repository }}/releases/download/v${VERSION}/${REPO_NAME}-${VERSION}.tar.gz", + "version": "${VERSION}" + } + EOF + + jq '.' ${MODULE_NAME}.json + + bazel run //tools:add_module -- \ + --input=${MODULE_NAME}.json + + git diff + - name: CREATE PULL REQUEST + uses: peter-evans/create-pull-request@v5.0.2 + with: + token: ${{ secrets.REPO_SCOPED_TOKEN }} + path: bazel-central-registry + title: Add ${{ github.repository }}@${{ github.ref_name }} + body: > + Automated changes created by + ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} + using the [create-pull-request](https://github.com/peter-evans/create-pull-request) + GitHub action in the ${{ github.workflow }} workflow. + commit-message: | + Add ${{ github.repository }}@${{ github.ref_name }} + branch: add-${{ github.repository }}@${{ github.ref_name }} + delete-branch: true diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 2d58e313..3d84bf44 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -43,7 +43,6 @@ jobs: uses: ncipollo/release-action@v1.12.0 with: allowUpdates: true - draft: true artifactErrorsFailBuild: true updateOnlyUnreleased: true generateReleaseNotes: true