diff --git a/.bcr/metadata.template.json b/.bcr/metadata.template.json new file mode 100644 index 0000000..60b6f87 --- /dev/null +++ b/.bcr/metadata.template.json @@ -0,0 +1,16 @@ +{ + "homepage": "https://github.com/stackb/jvm_image", + "maintainers": [ + { + "name": "Paul Johnston", + "email": "pcj@stack.build", + "github": "pcj", + "github_user_id": 50580 + } + ], + "repository": [ + "github:stackb/jvm_image" + ], + "versions": [], + "yanked_versions": {} +} diff --git a/.bcr/presubmit.yml b/.bcr/presubmit.yml new file mode 100644 index 0000000..08475b2 --- /dev/null +++ b/.bcr/presubmit.yml @@ -0,0 +1,12 @@ +bcr_test_module: + module_path: "example/hello" + matrix: + platform: ["macos", "ubuntu2204"] + bazel: ["8.*"] + tasks: + build_example: + name: "Build example image" + platform: ${{ platform }} + bazel: ${{ bazel }} + build_targets: + - "//:image" diff --git a/.bcr/source.template.json b/.bcr/source.template.json new file mode 100644 index 0000000..2037471 --- /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}/{REPO}-{TAG}.tar.gz" +} diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml new file mode 100644 index 0000000..1f41bb9 --- /dev/null +++ b/.github/workflows/publish.yml @@ -0,0 +1,33 @@ +name: Publish to BCR + +on: + workflow_call: + inputs: + tag_name: + required: true + type: string + secrets: + BCR_PUBLISH_TOKEN: + required: false + publish_token: + required: true + workflow_dispatch: + inputs: + tag_name: + description: Existing release tag to publish + required: true + type: string + +jobs: + publish: + uses: bazel-contrib/publish-to-bcr/.github/workflows/publish.yaml@c316f1611511a40423572303f66c80bb30bfe2f8 # v1.4.1 + with: + tag_name: ${{ inputs.tag_name }} + registry_fork: stackb/bazel-central-registry + draft: true + permissions: + attestations: write + contents: write + id-token: write + secrets: + publish_token: ${{ secrets.publish_token || secrets.BCR_PUBLISH_TOKEN }} diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..8a7d22b --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,43 @@ +name: Release + +on: + push: + tags: + - "v*.*.*" + workflow_dispatch: + inputs: + tag_name: + description: Existing tag to release + required: true + type: string + +permissions: + attestations: write + contents: write + id-token: write + +jobs: + release: + uses: bazel-contrib/.github/.github/workflows/release_ruleset.yaml@1d798ff015ed0696433e01e2c3ccbb2abefadad7 # v7.7.0 + with: + release_files: jvm_image-*.tar.gz + prerelease: false + draft: true + tag_name: ${{ inputs.tag_name || github.ref_name }} + + publish: + needs: release + uses: ./.github/workflows/publish.yml + with: + tag_name: ${{ inputs.tag_name || github.ref_name }} + secrets: + publish_token: ${{ secrets.BCR_PUBLISH_TOKEN }} + + finalize: + needs: publish + runs-on: ubuntu-latest + steps: + - name: Publish GitHub release + uses: softprops/action-gh-release@718ea10b132b3b2eba29c1007bb80653f286566b # v3.0.1 + with: + tag_name: ${{ inputs.tag_name || github.ref_name }} diff --git a/.github/workflows/release_prep.sh b/.github/workflows/release_prep.sh new file mode 100755 index 0000000..0fad57a --- /dev/null +++ b/.github/workflows/release_prep.sh @@ -0,0 +1,34 @@ +#!/usr/bin/env bash + +set -o errexit -o nounset -o pipefail + +readonly TAG="${1:?release tag is required}" +if [[ ! "$TAG" =~ ^v[0-9]+\.[0-9]+\.[0-9]+([.-][0-9A-Za-z.-]+)?$ ]]; then + echo "release tag must be a semantic version prefixed with v: $TAG" >&2 + exit 1 +fi + +if [[ ! -f LICENSE && ! -f LICENSE.txt && ! -f LICENSE.md ]]; then + echo "a repository license is required before publishing a release" >&2 + exit 1 +fi + +readonly VERSION="${TAG#v}" +readonly PREFIX="jvm_image-${VERSION}" +readonly ARCHIVE="jvm_image-${TAG}.tar.gz" + +git archive --format=tar --prefix="${PREFIX}/" "$TAG" | gzip -n >"$ARCHIVE" +SHA256="$(shasum -a 256 "$ARCHIVE" | awk '{print $1}')" +readonly SHA256 + +cat <