Skip to content

Commit

Permalink
fix: generate release .tgz and correct checksum (#57)
Browse files Browse the repository at this point in the history
Closes #56
  • Loading branch information
ryanleary authored Jan 2, 2023
1 parent 39be9bb commit a81b6bc
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 29 deletions.
14 changes: 14 additions & 0 deletions .github/release_notes.template
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
## `WORKSPACE` code
```starlark
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
http_archive(
name = "rules_cuda",
sha256 = "{archive_sha256}",
strip_prefix = "rules_cuda-{version}",
urls = ["https://github.com/bazel-contrib/rules_cuda/releases/download/{version}/rules_cuda-{version}.tar.gz"],
)

load("@rules_cuda//cuda:repositories.bzl", "register_detected_cuda_toolchains", "rules_cuda_dependencies")
rules_cuda_dependencies()
register_detected_cuda_toolchains()
```
31 changes: 28 additions & 3 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,37 @@ jobs:
# Bazelisk will download bazel to here
XDG_CACHE_HOME: ~/.cache/bazel-repo
run: bazelisk --bazelrc=.github/workflows/ci.bazelrc --bazelrc=.bazelrc test //...
- name: Create rules archive
run: |
PREFIX="rules_cuda-${GITHUB_REF_NAME}"
git archive --format=tar.gz --prefix=${PREFIX}/ ${GITHUB_REF_NAME} -o ${{ github.workspace }}/.github/rules_cuda.tar.gz
echo "ARCHIVE_SHA256=$(shasum -a 256 ${{ github.workspace }}/.github/rules_cuda.tar.gz | cut -d ' ' -f 1)" >> $GITHUB_ENV
echo "RELEASE_VERSION=${GITHUB_REF_NAME}" >> $GITHUB_ENV
# Upload the artifact in case creating a release fails so all artifacts can then be manually recovered.
- uses: actions/upload-artifact@v2
with:
name: "rules_cuda.tar.gz"
path: ${{ github.workspace }}/.github/rules_cuda.tar.gz
if-no-files-found: error
- name: Prepare workspace snippet
run: .github/workflows/workspace_snippet.sh $GITHUB_REF_NAME > release_notes.txt
- name: Release
run: |
sed 's/{version}/${{ env.RELEASE_VERSION }}/g' ${{ github.workspace }}/.github/release_notes.template \
| sed 's/{archive_sha256}/${{ env.ARCHIVE_SHA256 }}/g' \
> ${{ github.workspace }}/.github/release_notes.txt
- name: Create the release
uses: softprops/action-gh-release@v1
id: rules_cuda_release
with:
prerelease: true
# Use GH feature to populate the changelog automatically
generate_release_notes: true
body_path: release_notes.txt
body_path: ${{ github.workspace }}/.github/release_notes.txt
- name: "Upload the rules archive"
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.rules_cuda_release.outputs.upload_url }}
asset_name: rules_cuda-${{ env.RELEASE_VERSION }}.tar.gz
asset_path: ${{ github.workspace }}/.github/rules_cuda.tar.gz
asset_content_type: application/gzip
24 changes: 0 additions & 24 deletions .github/workflows/workspace_snippet.sh

This file was deleted.

2 changes: 0 additions & 2 deletions examples/WORKSPACE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ local_repository(
path = "../",
)

#---SNIP--- Below here is re-used in the workspace snippet published on releases

######################
# rules_bazel setup #
######################
Expand Down

0 comments on commit a81b6bc

Please sign in to comment.