diff --git a/.github/workflows/BUILD.bazel b/.github/workflows/BUILD.bazel index 9960e59..413ab5b 100644 --- a/.github/workflows/BUILD.bazel +++ b/.github/workflows/BUILD.bazel @@ -2,13 +2,6 @@ load("@aspect_bazel_lib//lib:write_source_files.bzl", "write_source_files") load("@buildifier_prebuilt//:rules.bzl", "buildifier") load("@rules_abcue//cue:defs.bzl", "cue_export", "cue_instance") -write_source_files( - name = "yaml", - files = { - "ci_gen.yaml": ":ci", - }, -) - buildifier( name = "buildifier.check", exclude_patterns = ["./.git/*"], @@ -23,10 +16,27 @@ cue_instance( ancestor = "//cue.mod", ) -cue_export( - name = "ci", - out = "yaml", - expression = "ci", - instance = ":workflows", - package = "workflows", +EXPR = [ + "buildifier", + "ci", + "release", +] + +[ + cue_export( + name = n, + out = "yaml", + expression = n, + instance = ":workflows", + package = "workflows", + ) + for n in EXPR +] + +write_source_files( + name = "yaml", + files = { + n + "_gen.yaml": ":" + n + for n in EXPR + }, ) diff --git a/.github/workflows/buildifier.yaml b/.github/workflows/buildifier.yaml deleted file mode 100644 index 9a493c2..0000000 --- a/.github/workflows/buildifier.yaml +++ /dev/null @@ -1,19 +0,0 @@ -name: Buildifier - -# Controls when the action will run. -on: - # Triggers the workflow on push or pull request events but only for the main branch - push: - branches: [main] - pull_request: - branches: [main] - # Allows you to run this workflow manually from the Actions tab - workflow_dispatch: - -jobs: - check: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - name: buildifier - run: bazel run --enable_bzlmod //.github/workflows:buildifier.check diff --git a/.github/workflows/buildifier_gen.yaml b/.github/workflows/buildifier_gen.yaml new file mode 100644 index 0000000..1a398af --- /dev/null +++ b/.github/workflows/buildifier_gen.yaml @@ -0,0 +1,16 @@ +name: Buildifier +"on": + push: + branches: + - main + pull_request: + branches: + - main + workflow_dispatch: null +jobs: + check: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: buildifier + run: bazel run --enable_bzlmod //.github/workflows:buildifier.check diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml deleted file mode 100644 index 0e35d1b..0000000 --- a/.github/workflows/release.yml +++ /dev/null @@ -1,18 +0,0 @@ -# Cut a release whenever a new tag is pushed to the repo. -# You should use an annotated tag, like `git tag -a v1.2.3` -# and put the release notes into the commit message for the tag. -name: Release - -on: - push: - tags: - - "v*.*.*" - -permissions: - contents: write - -jobs: - release: - uses: bazel-contrib/.github/.github/workflows/release_ruleset.yaml@v6 - with: - release_files: rules_abcue-*.tar.gz diff --git a/.github/workflows/release_gen.yaml b/.github/workflows/release_gen.yaml new file mode 100644 index 0000000..825577a --- /dev/null +++ b/.github/workflows/release_gen.yaml @@ -0,0 +1,12 @@ +name: Release +"on": + push: + tags: + - v*.*.* +permissions: + contents: write +jobs: + release: + uses: bazel-contrib/.github/.github/workflows/release_ruleset.yaml@v6 + with: + release_files: rules_abcue-*.tar.gz diff --git a/.github/workflows/workflows.cue b/.github/workflows/workflows.cue index c7a612e..a9858ef 100644 --- a/.github/workflows/workflows.cue +++ b/.github/workflows/workflows.cue @@ -2,6 +2,28 @@ package workflows import "encoding/json" +buildifier: { + name: "Buildifier" + + // Controls when the action will run. + on: { + // Triggers the workflow on push or pull request events but only for the main branch + push: branches: ["main"] + pull_request: branches: ["main"] + // Allows you to run this workflow manually from the Actions tab + workflow_dispatch: null + } + jobs: check: { + "runs-on": "ubuntu-latest" + steps: [{ + uses: "actions/checkout@v4" + }, { + name: "buildifier" + run: "bazel run --enable_bzlmod //.github/workflows:buildifier.check" + }] + } +} + ci: { // Controls when the action will run. on: { @@ -35,3 +57,16 @@ ci: { } } } + +release: { + // Cut a release whenever a new tag is pushed to the repo. + // You should use an annotated tag, like `git tag -a v1.2.3` + // and put the release notes into the commit message for the tag. + name: "Release" + on: push: tags: ["v*.*.*"] + permissions: contents: "write" + jobs: release: { + uses: "bazel-contrib/.github/.github/workflows/release_ruleset.yaml@v6" + with: release_files: "rules_abcue-*.tar.gz" + } +}