-
Notifications
You must be signed in to change notification settings - Fork 8
106 lines (89 loc) · 3.79 KB
/
sync-on-llvm-version.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
name: "Sync on LLVM version"
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: 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.
regenerate-assets:
name: "(Re)generate assets"
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 snapshot-version-sync \
--delete-older 33 \
--delete-today
- name: Determine good commit (on schedule only)
uses: ./.github/actions/get-good-commit
id: good-commit
with:
token: ${{ secrets.GITHUB_TOKEN }}
checkout-path: .
github-project: llvm/llvm-project
start-ref: main
max-tries: 100
- name: "Generate snapshot version info"
shell: bash -e {0}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
if [[ "${{github.event_name}}" == "workflow_dispatch" ]]; then
commit_hash=${{inputs.commit_hash}}
else
commit_hash=${{ steps.good-commit.outputs.good-commit }}
fi
if [[ "$commit_hash" =~ ^[0-9a-f]{40}$ ]]; then
echo "commit_hash looks like a SHA1. No need to resolve: ${commit_hash}"
else
echo "commit_hash doesn't look like a SHA1 (maybe it is a branch or tag name). Trying to resolve it: ${commit_hash}"
# See https://docs.github.com/de/rest/commits/commits?apiVersion=2022-11-28#list-branches-for-head-commit
commit_hash=`curl -L \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer ${{env.GITHUB_TOKEN}}" \
-H "X-GitHub-Api-Version: 2022-11-28" \
https://api.github.com/repos/llvm/llvm-project/commits/${commit_hash}/branches-where-head \
| jq -r '.[0].commit.sha'`
fi
echo "commit_hash=${commit_hash}" >> $GITHUB_ENV
yyyymmdd=$(date +%Y%m%d)
versionfile=LLVMVersion.cmake
url=https://raw.githubusercontent.com/llvm/llvm-project/${commit_hash}/cmake/Modules/${versionfile}
echo "Getting ${url}"
curl -sL -o ${versionfile} ${url}
echo "Version file:"
cat ${versionfile}
llvm_snapshot_git_revision=${commit_hash}
llvm_snapshot_version=`grep -ioP 'set\(\s*LLVM_VERSION_(MAJOR|MINOR|PATCH)\s\K[0-9]+' ${versionfile} | paste -sd '.'`
echo "${llvm_snapshot_version}" > llvm-release-${yyyymmdd}.txt
echo "${llvm_snapshot_git_revision}" > llvm-git-revision-${yyyymmdd}.txt
echo "llvm_release=`cat llvm-release-${yyyymmdd}.txt`"
echo "llvm_git_revision=`cat llvm-git-revision-${yyyymmdd}.txt`"
./scripts/upload-source-snapshots.py \
--token ${{ secrets.GITHUB_TOKEN }} \
--project ${{ github.repository }} \
--release-name snapshot-version-sync \
--yyyymmdd "$(date +%Y%m%d)"