Skip to content

Commit

Permalink
Update github actions
Browse files Browse the repository at this point in the history
  • Loading branch information
jbarr21 authored and oliviernotteghem committed Jul 31, 2024
1 parent ebeb827 commit 28e47af
Show file tree
Hide file tree
Showing 3 changed files with 85 additions and 31 deletions.
20 changes: 20 additions & 0 deletions .github/workflows/ci.bazelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# This file contains Bazel settings to apply on CI only.
# It is referenced with a --bazelrc option in the call to bazel in ci.yaml
common --curses=no
#common --enable_bzlmod

build --verbose_failures
build --worker_verbose

# Debug where options came from
build --announce_rc
# This directory is configured in GitHub actions to be persisted between runs.
# We do not enable the repository cache to cache downloaded external artifacts
# as these are generally faster to download again than to fetch them from the
# GitHub actions cache.
build --disk_cache=~/.cache/bazel
# Don't rely on test logs being easily accessible from the test runner,
# though it makes the log noisier.
test --test_output=errors
# Allows tests to run bazelisk-in-bazel, since this is the cache folder used
test --test_env=XDG_CACHE_HOME
58 changes: 27 additions & 31 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,45 +1,41 @@
# 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 Binary Package
on:
push:
tags:
- v*
- "v*"

jobs:
generate:
name: Create release-artifacts
build:
runs-on: ubuntu-latest
steps:
- name: "Checkout the sources"
uses: actions/[email protected]
- name: Checkout
uses: actions/checkout@v3
- name: Mount bazel caches
uses: actions/cache@v3
with:
path: |
~/.cache/bazel
key: bazel-cache-${{ hashFiles('**/BUILD.bazel', '**/*.bzl', 'WORKSPACE', 'WORKSPACE.bzlmod') }}
restore-keys: bazel-cache-
- name: Install JDK 11
uses: actions/setup-java@v3
with:
distribution: "zulu"
java-version: "11"
- name: Setup Bazelisk
uses: bazelbuild/setup-bazelisk@v1
- name: Mount bazel cache
uses: actions/cache@v2
with:
path: "/home/runner/.cache/bazel"
key: caches-${{ runner.os }}-release
- name: Build release artifact
run: bazelisk build //:rules_kotlin_release
- name: Create release sha256
run: shasum -a 256 bazel-bin/rules_kotlin_release.tgz > bazel-bin/rules_kotlin_release.tgz.sha256
- name: Upload bazel-bin/rules_kotlin_release.tgz
uses: svenstaro/[email protected]
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: bazel-bin/rules_kotlin_release.tgz
asset_name: rules_kotlin_release.tgz
tag: ${{ github.ref }}
overwrite: true
- name: Upload bazel-bin/rules_kotlin_release.tgz.sha256
uses: svenstaro/[email protected]
- name: Prepare release notes and artifacts
env:
# Bazelisk will download bazel to here.
XDG_CACHE_HOME: ~/.cache/bazel-repo
run: .github/workflows/release_prep.sh ${{ env.GITHUB_REF_NAME }}
- name: Release
uses: softprops/action-gh-release@v1
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: bazel-bin/rules_kotlin_release.tgz.sha256
asset_name: rules_kotlin_release.tgz.sha256
tag: ${{ github.ref }}
overwrite: true
prerelease: true
# Use GH feature to populate the changelog automatically
generate_release_notes: true
body_path: release_notes.txt
fail_on_unmatched_files: true
files: rules_kotlin-*.tar.gz
38 changes: 38 additions & 0 deletions .github/workflows/release_prep.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#!/usr/bin/env bash

set -o errexit -o nounset -o pipefail

# Set by GH actions, see
# https://docs.github.com/en/actions/learn-github-actions/environment-variables#default-environment-variables
TAG=${GITHUB_REF_NAME}
# The prefix is chosen to match what GitHub generates for source archives
PREFIX="rules_kotlin-${TAG:1}"
ARCHIVE="rules_kotlin-$TAG.tar.gz"
bazel --bazelrc=.github/workflows/ci.bazelrc --bazelrc=.bazelrc build //:rules_kotlin_release
cp bazel-bin/rules_kotlin_release.tgz $ARCHIVE
SHA=$(shasum -a 256 $ARCHIVE | awk '{print $1}')

# Write the release notes to release_notes.txt
cat > release_notes.txt << EOF
# Release notes for $TAG
## Using Bzlmod with Bazel 6
1. Enable with \`common --enable_bzlmod\` in \`.bazelrc\`.
2. Add to your \`MODULE.bazel\` file:
\`\`\`starlark
bazel_dep(name = "rules_kotlin", version = "${TAG:1}")
\`\`\`
## Using WORKSPACE
Paste this snippet into your \`WORKSPACE.bazel\` file:
\`\`\`starlark
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
http_archive(
name = "rules_kotlin",
sha256 = "${SHA}",
url = "https://github.com/bazelbuild/rules_kotlin/releases/download/${TAG}/${ARCHIVE}",
)
EOF

0 comments on commit 28e47af

Please sign in to comment.