Skip to content

Commit ecb8904

Browse files
authored
When a release is published, upload a stable source archive. (#1464)
* When a release is published, upload a stable source archive. Add a new github actions script to release a 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 * Use actions/checkout without a commit hash.
1 parent 7bd92c6 commit ecb8904

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
name: Publish Stable Source Archive
2+
3+
on:
4+
release:
5+
types: [published]
6+
7+
jobs:
8+
# Whenever a release is published, this uploads an accompanying stable source archive.
9+
#
10+
# Github doesn't guarantee stability of source archives for more than 6 months[1].
11+
# More stability is required by projects like Bazel Central Registry[2][3].
12+
#
13+
# [1]: https://github.blog/open-source/git/update-on-the-future-stability-of-source-code-archives-and-hashes/
14+
# [2]: https://github.com/bazelbuild/bazel-central-registry/blob/main/docs/README.md#validations
15+
# [3]: https://blog.bazel.build/2023/02/15/github-archive-checksum.html
16+
bazel-release-archive:
17+
defaults:
18+
run:
19+
# https://vaneyckt.io/posts/safer_bash_scripts_with_set_euxo_pipefail/
20+
shell: /usr/bin/bash -euxo pipefail {0}
21+
env:
22+
# github.ref_name is defined here:
23+
# https://docs.github.com/en/actions/writing-workflows/choosing-what-your-workflow-does/accessing-contextual-information-about-workflow-runs#github-context
24+
TAG: ${{github.ref_name}}
25+
runs-on: ubuntu-latest
26+
permissions:
27+
contents: write
28+
steps:
29+
- uses: actions/checkout
30+
# GITHUB_REF is defined here:
31+
# https://docs.github.com/en/actions/writing-workflows/choosing-what-your-workflow-does/store-information-in-variables#default-environment-variables
32+
- run: git archive --format zip --prefix "grpc-web-$TAG/" --output "grpc-web-source-${TAG}.zip" "$GITHUB_REF"
33+
- run: git archive --format tar.gz --prefix "grpc-web-$TAG/" --output "grpc-web-source-${TAG}.tar.gz" "$GITHUB_REF"
34+
- run: gh release upload "${TAG}" "grpc-web-source-${TAG}.zip" "grpc-web-source-${TAG}.tar.gz"
35+
env:
36+
GH_TOKEN: ${{ github.token }}

0 commit comments

Comments
 (0)