Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

When a release is published, upload a stable source archive. #5

Merged
merged 1 commit into from
Oct 7, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 36 additions & 0 deletions .github/workflows/release-source-archive.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: Publish Stable Source Archive

on:
release:
types: [published]

jobs:
# Whenever a release is published, this uploads an accompanying stable source archive.
#
# Github doesn't guarantee stability of source archives for more than 6 months[1].
# More stability is required by projects like Bazel Central Registry[2][3].
#
# [1]: https://github.blog/open-source/git/update-on-the-future-stability-of-source-code-archives-and-hashes/
# [2]: https://github.com/bazelbuild/bazel-central-registry/blob/main/docs/README.md#validations
# [3]: https://blog.bazel.build/2023/02/15/github-archive-checksum.html
bazel-release-archive:
defaults:
run:
# https://vaneyckt.io/posts/safer_bash_scripts_with_set_euxo_pipefail/
shell: /usr/bin/bash -euxo pipefail {0}
env:
# github.ref_name is defined here:
# https://docs.github.com/en/actions/writing-workflows/choosing-what-your-workflow-does/accessing-contextual-information-about-workflow-runs#github-context
TAG: ${{github.ref_name}}
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout
# GITHUB_REF is defined here:
# https://docs.github.com/en/actions/writing-workflows/choosing-what-your-workflow-does/store-information-in-variables#default-environment-variables
- run: git archive --format zip --prefix "pkg-with-runfiles-$TAG/" --output "pkg-with-runfiles-source-${TAG}.zip" "$GITHUB_REF"
- run: git archive --format tar.gz --prefix "pkg-with-runfiles-$TAG/" --output "pkg-with-runfiles-source-${TAG}.tar.gz" "$GITHUB_REF"
- run: gh release upload "${TAG}" "pkg-with-runfiles-source-${TAG}.zip" "pkg-with-runfiles-source-${TAG}.tar.gz"
env:
GH_TOKEN: ${{ github.token }}