Skip to content

Commit

Permalink
automate release process
Browse files Browse the repository at this point in the history
  • Loading branch information
apesternikov committed Apr 24, 2024
1 parent a99cc2a commit ebb2535
Show file tree
Hide file tree
Showing 7 changed files with 31 additions and 244 deletions.
2 changes: 1 addition & 1 deletion .github/CODEOWNERS
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#
# The default owners for everything in the repo.
#
* @adobe/rules_gitops
* @fasterci/rules_gitops
47 changes: 0 additions & 47 deletions .github/CONTRIBUTING.md

This file was deleted.

45 changes: 0 additions & 45 deletions .github/ISSUE_TEMPLATE.md

This file was deleted.

2 changes: 0 additions & 2 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,8 @@
<!--- Go over all the following points, and put an `x` in all the boxes that apply. -->
<!--- If you're unsure about any of these, don't hesitate to ask. We're here to help! -->

- [ ] I have signed the [Adobe Open Source CLA](https://opensource.adobe.com/cla.html).
- [ ] My code follows the code style of this project.
- [ ] My change requires a change to the documentation.
- [ ] I have updated the documentation accordingly.
- [ ] I have read the **CONTRIBUTING** document.
- [ ] I have added tests to cover my changes.
- [ ] All new and existing tests passed.
83 changes: 0 additions & 83 deletions .github/workflows/ci.yaml

This file was deleted.

68 changes: 4 additions & 64 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,78 +10,18 @@ on:

jobs:
build:
runs-on: ubuntu-20.04
env:
USE_BAZEL_VERSION: 5.3.1
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Mount Bazel cache
uses: actions/cache@v3
with:
path: ~/.cache/bazel
key: bazel-${{ env.USE_BAZEL_VERSION }}-${{ github.sha }}
restore-keys: |
bazel-${{ env.USE_BAZEL_VERSION }}-
bazel-
- name: Setup build tools
run: |
TOOLS_DIR="${HOME}/.cache/tools"
mkdir -p "${TOOLS_DIR}/bin/"
curl -Ls -o "${TOOLS_DIR}/bin/bazel" "https://github.com/bazelbuild/bazelisk/releases/download/v1.14.0/bazelisk-linux-amd64"
chmod +x "${TOOLS_DIR}/bin/bazel"
curl -Ls -o "${TOOLS_DIR}/bin/buildifier" "https://github.com/bazelbuild/buildtools/releases/download/0.29.0/buildifier"
chmod +x "${TOOLS_DIR}/bin/buildifier"
curl -Ls -o "${TOOLS_DIR}/bin/kind" "https://github.com/kubernetes-sigs/kind/releases/download/v0.11.1/kind-linux-amd64"
chmod +x "${TOOLS_DIR}/bin/kind"
echo "${TOOLS_DIR}/bin" >> $GITHUB_PATH
- name: Setup kind cluster
run: |
./create_kind_cluster.sh
- name: Build
run: |
bazel build //...
- name: Check
# run downloaded version of buildifier to reduce uncached build times
# see: bazel run //:buildifier-check
run: |
find . -type f \(\
-name '*.bzl' \
-o -name '*.sky' \
-o -name BUILD \
-o -name BUILD.bazel \
-o -name WORKSPACE \
-o -name WORKSPACE.bazel \
\) | xargs buildifier \
-mode=check \
-lint=warn \
--warnings=-module-docstring,-function-docstring,-function-docstring-header,-function-docstring-args,-function-docstring-return,-print \
|| {
buildifier_exit_code=$?
echo "Error: failed buildifier checks. Please run \"bazel run //:buildifier-fix\" and commit the changes."
exit $buildifier_exit_code
}
- name: Test
run: |
bazel test //...
- name: Build examples
run: |
cd examples
bazel build //...
- name: Test examples
run: |
cd examples
bazel test //...
- name: E2E
run: |
cd examples
./e2e-test.sh
- name: Prepare workspace snippet
run: .github/workflows/workspace_snippet.sh ${{ env.GITHUB_REF_NAME }} > release_notes.txt
- name: Release
uses: softprops/action-gh-release@v1
uses: softprops/action-gh-release@v2
with:
prerelease: true
# Use GH feature to populate the changelog automatically
generate_release_notes: true
body_path: release_notes.txt
files: rules_gitops-*.tar.gz

28 changes: 26 additions & 2 deletions .github/workflows/workspace_snippet.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,36 @@

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_gitops-${TAG:1}"
ARCHIVE="rules_gitops-$TAG.tar.gz"
git archive --format=tar --prefix=${PREFIX}/ ${TAG} | gzip > $ARCHIVE
SHA=$(shasum -a 256 $ARCHIVE | awk '{print $1}')

set -o errexit -o nounset -o pipefail

TAG=${GITHUB_REF_NAME}
PREFIX="rules_gitops-${TAG:1}"
SHA=$(git archive --format=tar --prefix=${PREFIX}/ ${TAG} | gzip | shasum -a 256 | awk '{print $1}')

cat << EOF
## Using bzlmod with Bazel 6 or later:
1. Add \`common --enable_bzlmod\` to \`.bazelrc\`.
2. Add to your \`MODULE.bazel\` file:
\`\`\`starlark
bazel_dep(name = "rules_gitops", version = "${TAG:1}")
kustomize = use_extension("@rules_gitops//gitops:extensions.bzl", "kustomize")
kustomize.kustomize_toolchain()
use_repo(kustomize, "kustomize_bin")
\`\`\`
WORKSPACE snippet:
## Using WORKSPACE:
\`\`\`starlark
Expand All @@ -18,8 +41,9 @@ http_archive(
name = "rules_gitops",
sha256 = "${SHA}",
strip_prefix = "${PREFIX}",
urls = ["https://github.com/fasterci/rules_gitops/archive/refs/tags/${TAG}.tar.gz"],
urls = ["https://github.com/fasterci/rules_gitops/releases/download/${TAG}/${ARCHIVE}"],
)
\`\`\`
EOF

awk '/---SNIP---/{f=1;next}/---END_SNIP---/{f=0}f' examples/WORKSPACE
Expand Down

0 comments on commit ebb2535

Please sign in to comment.