Update release CI (#144)
This now generates an archive and uploads that to the releases to avoid
github tar change issues.
diff --git a/.bcr/source.template.json b/.bcr/source.template.json
index 274f5f6..0828ab6 100644
--- a/.bcr/source.template.json
+++ b/.bcr/source.template.json
@@ -1,5 +1,5 @@
{
- "url": "https://github.com/keith/buildifier-prebuilt/archive/refs/tags/{TAG}.tar.gz",
+ "url": "https://github.com/keith/buildifier-prebuilt/releases/download/{TAG}/buildifier-prebuilt.{TAG}.tar.gz",
"integrity": "",
- "strip_prefix": "buildifier-prebuilt-{TAG}"
+ "strip_prefix": ""
}
diff --git a/.github/generate-notes.sh b/.github/generate-notes.sh
new file mode 100755
index 0000000..6dab63b
--- /dev/null
+++ b/.github/generate-notes.sh
@@ -0,0 +1,42 @@
+#!/bin/bash
+
+set -euo pipefail
+
+readonly new_version=$1
+readonly archive=$2
+sha256=$(shasum -a 256 "$archive" | cut -d ' ' -f 1)
+
+cat <<EOF
+### MODULE.bazel Snippet
+
+\`\`\`bzl
+bazel_dep(name = "buildifier_prebuilt", version = "$new_version", dev_dependency = True)
+\`\`\`
+
+### WORKSPACE Snippet
+
+\`\`\`bzl
+load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
+
+http_archive(
+ name = "buildifier_prebuilt",
+ sha256 = "$sha256",
+ strip_prefix = "buildifier-prebuilt-$new_version",
+ urls = [
+ "http://github.com/keith/buildifier-prebuilt/archive/$new_version.tar.gz",
+ ],
+)
+
+load("@buildifier_prebuilt//:deps.bzl", "buildifier_prebuilt_deps")
+
+buildifier_prebuilt_deps()
+
+load("@bazel_skylib//:workspace.bzl", "bazel_skylib_workspace")
+
+bazel_skylib_workspace()
+
+load("@buildifier_prebuilt//:defs.bzl", "buildifier_prebuilt_register_toolchains")
+
+buildifier_prebuilt_register_toolchains()
+\`\`\`
+EOF
diff --git a/.github/workflows/create_release.yml b/.github/workflows/create_release.yml
index 1e0a455..db17fe0 100644
--- a/.github/workflows/create_release.yml
+++ b/.github/workflows/create_release.yml
@@ -3,38 +3,25 @@
on:
workflow_dispatch:
inputs:
- release_tag:
+ tag:
+ description: 'The new version to tag, ex: 1.0.5'
required: true
type: string
- base_branch:
- description: The branch being merged to.
- type: string
- default: main
jobs:
create_release:
runs-on: ubuntu-latest
- env:
- CC: clang
-
steps:
- # Checkout the code
- - uses: actions/checkout@v2
-
- # Generate a token that has permission to create a PR to update the README.md.
- - uses: tibdex/github-app-token@v1
- id: generate_token
- with:
- app_id: ${{ secrets.APP_ID }}
- private_key: ${{ secrets.APP_PRIVATE_KEY }}
-
- # Set up the git user to create a comiit (e.g. set user.name and user.email)
- - uses: cgrindel/gha_configure_git_user@v1
-
- # Create the release
- - uses: cgrindel/gha_create_release@v1
- with:
- release_tag: ${{ github.event.inputs.release_tag }}
- base_branch: ${{ github.event.inputs.base_branch }}
- github_token: ${{ steps.generate_token.outputs.token }}
-
+ - name: Checkout
+ uses: actions/checkout@v2
+ - name: Create Release
+ run: |
+ set -euo pipefail
+ archive="buildifier-prebuilt.$TAG.tar.gz"
+ COPYFILE_DISABLE=1 tar czvf "$archive" ./*
+ gh api repos/${{ github.repository }}/releases/generate-notes -f tag_name="$TAG" -f target_commitish="$GITHUB_REF_NAME" --jq .body > notes.md
+ ./.github/generate-notes.sh "$TAG" "$archive" >> notes.md
+ gh release create "$TAG" --title "$TAG" --target "$GITHUB_REF_NAME" --notes-file notes.md "$archive"
+ env:
+ TAG: ${{ inputs.tag }}
+ GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
diff --git a/MODULE.bazel b/MODULE.bazel
index 8389ad5..eb955b5 100644
--- a/MODULE.bazel
+++ b/MODULE.bazel
@@ -1,6 +1,6 @@
module(
name = "buildifier_prebuilt",
- version = "6.0.0.1",
+ version = "0",
compatibility_level = 1,
)
@@ -18,11 +18,6 @@
register_toolchains("@buildifier_prebuilt_toolchains//:all")
bazel_dep(
- name = "cgrindel_bazel_starlib",
- version = "0.28.0",
- dev_dependency = True,
-)
-bazel_dep(
name = "rules_bazel_integration_test",
version = "0.36.0",
dev_dependency = True,
diff --git a/README.md b/README.md
index 084f0d0..6ae36e5 100644
--- a/README.md
+++ b/README.md
@@ -40,56 +40,13 @@
## Installation
-### Bzlmod: Add `bazel_dep` to `MODULE.bazel` file
-
-<!-- BEGIN MODULE SNIPPET -->
-```python
-bazel_dep(
- name = "buildifier_prebuilt",
- version = "8.5.1.1",
- dev_dependency = True,
-)
-```
-<!-- END MODULE SNIPPET -->
-
-
-### Legacy: Add declarations to `WORKSPACE` file
-
-Add the following to your `WORKSPACE` file.
-
-<!-- BEGIN WORKSPACE SNIPPET -->
-```python
-load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
-
-http_archive(
- name = "buildifier_prebuilt",
- sha256 = "6a3514b5b1066101a0f0a810fc408598d198b78de5e9a56d2a2533d0022234ca",
- strip_prefix = "buildifier-prebuilt-8.5.1.1",
- urls = [
- "http://github.com/keith/buildifier-prebuilt/archive/8.5.1.1.tar.gz",
- ],
-)
-
-load("@buildifier_prebuilt//:deps.bzl", "buildifier_prebuilt_deps")
-
-buildifier_prebuilt_deps()
-
-load("@bazel_skylib//:workspace.bzl", "bazel_skylib_workspace")
-
-bazel_skylib_workspace()
-
-load("@buildifier_prebuilt//:defs.bzl", "buildifier_prebuilt_register_toolchains")
-
-buildifier_prebuilt_register_toolchains()
-```
-<!-- END WORKSPACE SNIPPET -->
-
+Check [the releases](releases) page for the latest snippet.
## Specify Version of Buildtools
-By default releases of these rules hardcode the most up to date versions of the tools at release
-time. If you would like to specify a specific version of buildtools to use, you can do one of the
-following.
+By default these rules use the buildifier and buildozer versions that
+match the release version on this repo. If you want to use a custom
+version, you can use one of the options below.
### Option 1: Manually Add SHA256 Values
@@ -197,6 +154,3 @@
),
)
```
-
-NOTE: The utility uses the [GitHub CLI](https://cli.github.com/). If you haven't already done so,
-install it.
diff --git a/release/BUILD b/release/BUILD
deleted file mode 100644
index 150c8ad..0000000
--- a/release/BUILD
+++ /dev/null
@@ -1,39 +0,0 @@
-load(
- "@cgrindel_bazel_starlib//bzlrelease:defs.bzl",
- "create_release",
- "generate_module_snippet",
- "generate_release_notes",
- "generate_workspace_snippet",
- "update_readme",
-)
-
-# MARK: - Release
-
-generate_module_snippet(
- name = "generate_module_snippet",
- dev_dependency = True,
- module_name = "buildifier_prebuilt",
-)
-
-generate_workspace_snippet(
- name = "generate_workspace_snippet",
- template = "workspace_snippet.tmpl",
- workspace_name = "buildifier_prebuilt",
-)
-
-generate_release_notes(
- name = "generate_release_notes",
- generate_module_snippet = ":generate_module_snippet",
- generate_workspace_snippet = ":generate_workspace_snippet",
-)
-
-update_readme(
- name = "update_readme",
- generate_module_snippet = ":generate_module_snippet",
- generate_workspace_snippet = ":generate_workspace_snippet",
-)
-
-create_release(
- name = "create",
- workflow_name = "Create Release",
-)
diff --git a/release/README.md b/release/README.md
deleted file mode 100644
index c20319f..0000000
--- a/release/README.md
+++ /dev/null
@@ -1,32 +0,0 @@
-# Release Process for buildifier-prebuilt
-
-This document describes how to create a release.
-
-
-## How to Create a Release
-
-Once all of the code for a release has been merged to `main`, the release process can be started
-using the command line or the GitHub Actions web interface.
-
-
-### Create Release from Command Line
-
-The release process can be started by executing the `//release:create` target specifying the desired
-release tag (e.g. 1.2.3). To create a release tagged with `0.1.4`, one would run the following:
-
-```sh
-# Launch release GitHub Actions release workflow for 0.1.4
-$ bazel run //release:create -- 0.1.4
-```
-
-## Create Release from GitHub Actions Web Interface
-
-To start the release process from the GitHub Actions web interface,
-
-1. Navigate to the [Create
- Release](https://github.com/keith/buildifier-prebuilt/actions/workflows/create_release.yml)
- workflow page.
-2. Click the `Run workflow` dropdown button. It is located on the right-hand side of the page under
- the workflow execution filter controls.
-3. In the `release_tag` textbox, enter the release tag that should be created (e.g. `1.2.3`).
-4. Click the green `Run workflow` button.
diff --git a/release/workspace_snippet.tmpl b/release/workspace_snippet.tmpl
deleted file mode 100644
index 35a56e3..0000000
--- a/release/workspace_snippet.tmpl
+++ /dev/null
@@ -1,15 +0,0 @@
-load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
-
-${http_archive_statement}
-
-load("@buildifier_prebuilt//:deps.bzl", "buildifier_prebuilt_deps")
-
-buildifier_prebuilt_deps()
-
-load("@bazel_skylib//:workspace.bzl", "bazel_skylib_workspace")
-
-bazel_skylib_workspace()
-
-load("@buildifier_prebuilt//:defs.bzl", "buildifier_prebuilt_register_toolchains")
-
-buildifier_prebuilt_register_toolchains()