Generate LLVM snapshot tarballs #910
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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: | |
# Uncomment to be able to trigger the workflow manually | |
# See https://docs.github.com/en/actions/reference/events-that-trigger-workflows#manual-events | |
workflow_dispatch: {} | |
schedule: | |
# Everyday at 00:00am | |
# See https://docs.github.com/en/actions/reference/events-that-trigger-workflows#schedule | |
- cron: '0 0 * * *' | |
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 | |
- uses: ./llvm-snapshots/.github/actions/get-good-commit | |
id: good-commit | |
with: | |
token: ${{ secrets.GITHUB_TOKEN }} | |
checkout-path: llvm-snapshots | |
github-project: llvm/llvm-project | |
start-ref: main | |
- 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 stable revision to archive" | |
run: git -C llvm-project fetch --depth=1 --no-tags origin ${{ steps.good-commit.outputs.good-commit }} | |
- name: "create source-snapshot tarballs" | |
run: | | |
llvm-project/llvm/utils/release/export.sh \ | |
--git-ref ${{ steps.good-commit.outputs.good-commit }} \ | |
--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)" |