Skip to content

Commit 50424a6

Browse files
bigfootjonfacebook-github-bot
authored andcommitted
Add github action to auto-release TagIt tags
Summary: This came from a [request from Fred Emmott](https://fb.workplace.com/groups/osssupport/permalink/4116491528399431/), but also is something we should do due to the GitHub UI redesign: Nowadays on GitHub, tags are not shown in the sidebar (just the count) and instead GitHub Releases are prioritized and the most recent *release* is shown. Secondly, the Source Code zip archives for tags/releases are created on-the-fly on GitHub. This can cause problems for downstream projects that need consistent content hashes of the archive for security/reproducability reasons. This action also creates its own archives (zip and tar.gz) and attaches them to the release. Reviewed By: fredemmott Differential Revision: D23167073 fbshipit-source-id: 463e9d93a2c4af260ac3c4dbc1ceab7894add714
1 parent 4c15109 commit 50424a6

File tree

1 file changed

+68
-0
lines changed

1 file changed

+68
-0
lines changed

Diff for: .github/workflows/TagIt.yml

+68
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
on:
2+
push:
3+
tags:
4+
# Only match TagIt tags, which always start with this prefix
5+
- 'v20*'
6+
7+
name: TagIt
8+
9+
jobs:
10+
build:
11+
name: Release
12+
runs-on: ubuntu-latest
13+
steps:
14+
- name: Checkout code
15+
uses: actions/checkout@v2
16+
- name: Archive project
17+
id: archive_project
18+
run: |
19+
FILE_NAME=${GITHUB_REPOSITORY#*/}-${GITHUB_REF##*/}
20+
git archive ${{ github.ref }} -o ${FILE_NAME}.zip
21+
git archive ${{ github.ref }} -o ${FILE_NAME}.tar.gz
22+
echo "::set-output name=file_name::${FILE_NAME}"
23+
- name: Compute digests
24+
id: compute_digests
25+
run: |
26+
echo "::set-output name=tgz_256::$(openssl dgst -sha256 ${{ steps.archive_project.outputs.file_name }}.tar.gz)"
27+
echo "::set-output name=tgz_512::$(openssl dgst -sha512 ${{ steps.archive_project.outputs.file_name }}.tar.gz)"
28+
echo "::set-output name=zip_256::$(openssl dgst -sha256 ${{ steps.archive_project.outputs.file_name }}.zip)"
29+
echo "::set-output name=zip_512::$(openssl dgst -sha512 ${{ steps.archive_project.outputs.file_name }}.zip)"
30+
- name: Create Release
31+
id: create_release
32+
uses: actions/create-release@v1
33+
env:
34+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
35+
with:
36+
tag_name: ${{ github.ref }}
37+
release_name: ${{ github.ref }}
38+
body: |
39+
Automated release from TagIt
40+
<details>
41+
<summary>File Hashes</summary>
42+
<ul>
43+
<li>${{ steps.compute_digests.outputs.zip_256 }}</li>
44+
<li>${{ steps.compute_digests.outputs.zip_512 }}</li>
45+
<li>${{ steps.compute_digests.outputs.tgz_256 }}</li>
46+
<li>${{ steps.compute_digests.outputs.tgz_512 }}</li>
47+
</ul>
48+
</details>
49+
draft: false
50+
prerelease: false
51+
- name: Upload zip
52+
uses: actions/upload-release-asset@v1
53+
env:
54+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
55+
with:
56+
upload_url: ${{ steps.create_release.outputs.upload_url }}
57+
asset_path: ./${{ steps.archive_project.outputs.file_name }}.zip
58+
asset_name: ${{ steps.archive_project.outputs.file_name }}.zip
59+
asset_content_type: application/zip
60+
- name: Upload tar.gz
61+
uses: actions/upload-release-asset@v1
62+
env:
63+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
64+
with:
65+
upload_url: ${{ steps.create_release.outputs.upload_url }}
66+
asset_path: ./${{ steps.archive_project.outputs.file_name }}.tar.gz
67+
asset_name: ${{ steps.archive_project.outputs.file_name }}.tar.gz
68+
asset_content_type: application/gzip

0 commit comments

Comments
 (0)