-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Related to #12
- Loading branch information
Showing
5 changed files
with
195 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
name: Create Release | ||
|
||
on: | ||
workflow_dispatch: | ||
inputs: | ||
release_tag: | ||
required: true | ||
type: string | ||
reset_tag: | ||
type: boolean | ||
default: false | ||
base_branch: | ||
description: The branch being merged to. | ||
type: string | ||
default: main | ||
|
||
jobs: | ||
create_release: | ||
runs-on: ubuntu-latest | ||
env: | ||
CC: clang | ||
|
||
steps: | ||
|
||
# Check out your code | ||
- uses: actions/checkout@v2 | ||
|
||
# Generate a token that has permssions to create a release and create PRs. | ||
- uses: tibdex/github-app-token@v1 | ||
id: generate_token | ||
with: | ||
app_id: ${{ secrets.APP_ID }} | ||
private_key: ${{ secrets.APP_PRIVATE_KEY }} | ||
|
||
# Configure the git user for the repository | ||
- uses: cgrindel/gha_configure_git_user@v1 | ||
|
||
# Create the release | ||
- uses: cgrindel/gha_create_release@v1 | ||
with: | ||
release_tag: ${{ github.event.inputs.release_tag }} | ||
reset_tag: ${{ github.event.inputs.reset_tag }} | ||
base_branch: ${{ github.event.inputs.base_branch }} | ||
github_token: ${{ steps.generate_token.outputs.token }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
load("@cgrindel_bazel_starlib//bzlformat:defs.bzl", "bzlformat_pkg") | ||
load( | ||
"@cgrindel_bazel_starlib//bzlrelease:defs.bzl", | ||
"create_release", | ||
"generate_release_notes", | ||
"generate_workspace_snippet", | ||
"update_readme", | ||
) | ||
|
||
bzlformat_pkg(name = "bzlformat") | ||
|
||
# MARK: - Release | ||
|
||
generate_workspace_snippet( | ||
name = "generate_workspace_snippet", | ||
template = "workspace_snippet.tmpl", | ||
) | ||
|
||
generate_release_notes( | ||
name = "generate_release_notes", | ||
generate_workspace_snippet = ":generate_workspace_snippet", | ||
) | ||
|
||
update_readme( | ||
name = "update_readme", | ||
generate_workspace_snippet = ":generate_workspace_snippet", | ||
) | ||
|
||
create_release( | ||
name = "create", | ||
workflow_name = "Create Release", | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
# Release Process for `rules_spm` | ||
|
||
The release process for this repository is implemented using GitHub Actions and the [bzlrelease | ||
macros](https://github.com/cgrindel/bazel-starlib/tree/main/bzlrelease). 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 by | ||
executing the `//release:create` target specifying the desired release tag (e.g. v1.2.3). To create | ||
a release tagged with `v0.1.4`, one would run the following: | ||
|
||
```sh | ||
# Launch release GitHub Actions release workflow for v0.1.4 | ||
$ bazel run //release:create -- v0.1.4 | ||
``` | ||
|
||
This will launch the [release workflow](.github/workflows/create_release.yml). The workflow performs | ||
the following steps: | ||
|
||
1. Creates the specified tag at the HEAD of the main branch. | ||
2. Generates release notes. | ||
3. Creates a GitHub release. | ||
4. Updates the `README.md` with the latest workspace snippet information. | ||
5. Creates a PR with the updated `README.md` configured to auto-merge if all the checks pass. | ||
|
||
There are two ways that this process could fail. First, if an improperly formatted release tag is | ||
specified, the release workflow will fail. Be sure to prefix the release tag with `v`. Second, the | ||
PR that contains the updates to the README.md file could fail if the PR cannot be automatically | ||
merged. | ||
|
||
## Other Scenarios | ||
|
||
### Testing Changes to the Release Process | ||
|
||
If you are testing changes to the release workflows, you should make the desired changes in a | ||
branch, push the branch to `origin`, and then execute the `//release:create` target with the `--ref | ||
<branch_name>`. For instance, if the remote branch name is `fixes_for_release` and the next release | ||
is `v1.2.3`, then you would run the following: | ||
|
||
```sh | ||
$ bazel run //release:create -- v1.2.3 --ref fixes_for_release | ||
``` | ||
|
||
### Rerunning a Failed Release | ||
|
||
If you executed a release workflow and it failed without creating the release, you can rerun the | ||
workflow with the same tag adding the `--reset_tag` option. For instance, if you need to rerun the | ||
release for `v1.2.3`, you would run the following: | ||
|
||
```sh | ||
$ bazel run //release:create -- v1.2.3 --reset_tag | ||
``` | ||
|
||
If the failure occurred after the creation of the release, you have two options: | ||
|
||
1. Delete the release and run the release again with the `--reset_tag`; OR | ||
2. Create a new release with a new tag. | ||
|
||
One should be very careful with option #1 as clients may see the failed release and attempt to use | ||
it. Option #2 is always the safest path. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") | ||
|
||
${http_archive_statement} | ||
|
||
load("@cgrindel_swift_bazel//:deps.bzl", "swift_bazel_dependencies") | ||
|
||
swift_bazel_dependencies() | ||
|
||
load("@cgrindel_bazel_starlib//:deps.bzl", "bazel_starlib_dependencies") | ||
|
||
bazel_starlib_dependencies() | ||
|
||
# MARK: - Gazelle | ||
|
||
# gazelle:repo bazel_gazelle | ||
|
||
load("@bazel_gazelle//:deps.bzl", "gazelle_dependencies") | ||
load("@cgrindel_swift_bazel//:go_deps.bzl", "swift_bazel_go_dependencies") | ||
load("@io_bazel_rules_go//go:deps.bzl", "go_register_toolchains", "go_rules_dependencies") | ||
|
||
# Declare Go dependencies before calling go_rules_dependencies. | ||
swift_bazel_go_dependencies() | ||
|
||
go_rules_dependencies() | ||
|
||
go_register_toolchains(version = "1.19.1") | ||
|
||
gazelle_dependencies() | ||
|
||
# MARK: - Swift Toolchain | ||
|
||
http_archive( | ||
name = "build_bazel_rules_swift", | ||
# Populate with your preferred release | ||
# https://github.com/bazelbuild/rules_swift/releases | ||
) | ||
|
||
load( | ||
"@build_bazel_rules_swift//swift:repositories.bzl", | ||
"swift_rules_dependencies", | ||
) | ||
load("//:swift_deps.bzl", "swift_dependencies") | ||
|
||
# gazelle:repository_macro swift_deps.bzl%swift_dependencies | ||
swift_dependencies() | ||
|
||
swift_rules_dependencies() | ||
|
||
load( | ||
"@build_bazel_rules_swift//swift:extras.bzl", | ||
"swift_rules_extra_dependencies", | ||
) | ||
|
||
swift_rules_extra_dependencies() |