148 lines (132 loc) · 5.51 KB
/
generate-snapshot-tarballs.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
name: "Generate LLVM snapshot tarballs"
# PURPOSE:
#
# We want to provide LLVM snapshot packagers and distributors with *daily*
# source tarballs that are easy to consume. Typically, packagers have to clone
# the whole LLVM monorepo themselves and run the "git archive" command to
# generate source tarballs for each LLVM component. Those tarballs are the
# input to the packaging system (e.g. DEB, RPM, etc.). With this workflow we
# can provide the daily source tarballs to the community similar to the source
# tarballs of regular releases. Everything a packager needs to know is the
# current date (YYYYMMDD) and go ahead and download the LLVM component of
# choice, i.e.:
#
# https://github.com/fedora-llvm-team/llvm-snapshots/releases/download/source-snapshot/clang-tools-extra-20210417.src.tar.xz
#
# Notice the absence of the LLVM version. To get it, a packager can download
#
# https://github.com/fedora-llvm-team/llvm-snapshots/releases/download/source-snapshot/llvm-release-20210417.txt
#
# To get the git revision standalone:
#
# https://github.com/fedora-llvm-team/llvm-snapshots/releases/download/source-snapshot/llvm-git-revision-20210417.txt
#
# The subtle benefit of this naming convention is that you don't need to know
# the LLVM version before downloading the source tarball. I mean, how could
# you know the LLVM version of a daily snapshot upfront? In fact, the source
# tarball for "clang-tools-extra" contains no version information whatsoever
# and yet it requires a special LLVM version which is why we provide the
# "llvm-release-<YYYYMMDD>.txt" files.
#
# WHAT:
#
# At 00:00 in the morning, this workflow creates source tarballs for the
# latest stable commit of all LLVM components of the current "main" branch and
# uploads them as assets to a pre-release called "source-snapshot". (A
# pre-release won't show up on the github repositories front-page.) The assets
# that are seven days or older will be deleted on each run. If the workflow
# runs twice a day, the old assets of the day will also be deleted. If the
# "source-snapshot" release doesn't exist, it will be created automatically.
on:
schedule:
# Everyday at 00:00am
# See https://docs.github.com/en/actions/reference/events-that-trigger-workflows#schedule
- cron: '0 0 * * *'
workflow_dispatch:
inputs:
commit_hash:
description: 'Commit hash to use without tests'
required: true
default: origin/main
type: string
permissions:
# For release assets to be deletable we need this permission
contents: write
jobs:
# In order to re-build source snapshots and upload them, we must first delete
# the old ones from today; otherwise there would be a conflict. As a measure
# of not storing old snapshots for too long we'll delete older ones here as
# well.
delete-old-tarballs-and-todays:
name: "Delete old and today's tarballs"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 1
- uses: ./.github/actions/prepare-python
- name: "delete assets older than 33 days and from today"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
./scripts/delete-assets.py \
--token ${{ secrets.GITHUB_TOKEN }} \
--project ${{ github.repository }} \
--release-name source-snapshot \
--delete-older 33 \
--delete-today
generate-source-tarballs:
name: Generate snapshot tarballs
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 1
path: llvm-snapshots
- uses: ./llvm-snapshots/.github/actions/prepare-python
with:
checkout-path: llvm-snapshots
- name: Determine good commit (on schedule only)
uses: ./llvm-snapshots/.github/actions/get-good-commit
if: github.event_name != 'workflow_dispatch'
id: good-commit
with:
token: ${{ secrets.GITHUB_TOKEN }}
checkout-path: llvm-snapshots
github-project: llvm/llvm-project
start-ref: main
max-tries: 500
- name: "Variables and functions"
shell: bash -e {0}
run: |
if [[ "${{github.event_name}}" == "workflow_dispatch" ]]; then
echo "commit_hash=${{inputs.commit_hash}}" >> $GITHUB_ENV
else
echo "commit_hash=${{ steps.good-commit.outputs.good-commit }}" >> $GITHUB_ENV
fi
- name: "checkout llvm/llvm-project"
uses: actions/checkout@v4
with:
repository: llvm/llvm-project
ref: main
token: ${{ secrets.GITHUB_TOKEN }}
submodules: true
path: llvm-project
- name: "fetch LLVM revision to archive"
run: git -C llvm-project fetch --depth=1 --no-tags origin ${{ env.commit_hash }}
- name: "create source-snapshot tarballs"
run: |
llvm-project/llvm/utils/release/export.sh \
--git-ref ${{ env.commit_hash }} \
--template '${PROJECT}-${YYYYMMDD}.src.tar.xz'
- name: >-
upload source-snapshots and version files to the 'source-snapshot'
pre-release of ${{ github.repository }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
llvm-snapshots/scripts/upload-source-snapshots.py \
--token ${{ secrets.GITHUB_TOKEN }} \
--project ${{ github.repository }} \
--release-name source-snapshot \
--yyyymmdd "$(date +%Y%m%d)"