Skip to content

Commit 70b472e

Browse files
committed
add actions moved from workflow
1 parent 6fa3c81 commit 70b472e

File tree

3 files changed

+172
-0
lines changed

3 files changed

+172
-0
lines changed

actions/build/action.yml

Lines changed: 121 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,121 @@
1+
name: Prebuild LLVM and Swift
2+
description: Builds the prebuilt package needed by the CodeQL Swift extractor
3+
4+
runs:
5+
using: composite
6+
steps:
7+
### Prepare
8+
- name: Send workflow telemetry to Datadog
9+
uses: masci/datadog@863b639c95138e957eb6e1e2499cecb82040a10b
10+
with:
11+
api-key: '${{ secrets.DATADOG_API_KEY }}'
12+
metrics: |
13+
- type: count
14+
name: codeql_ci_workflow.count
15+
value: 1
16+
host: '${{ github.repository_owner }}'
17+
tags:
18+
- 'branch:${{ github.head_ref }}'
19+
- 'workflow:${{ github.workflow }}'
20+
- name: Workdir
21+
shell: bash
22+
run: |
23+
mkdir codeql-swift-prebuild
24+
25+
- name: Prepare (macOS)
26+
if: runner.os == 'macOS'
27+
shell: bash
28+
run: |
29+
brew install cmake
30+
pip install six
31+
32+
- name: Prepare (Linux)
33+
if: runner.os == 'Linux'
34+
shell: bash
35+
run: |
36+
sudo apt-get install -y cmake
37+
38+
### For debugging
39+
40+
- name: Dump environment
41+
shell: bash
42+
env:
43+
GITHUB_CONTEXT: '${{ toJson(github.event) }}'
44+
run: env | sort
45+
46+
- run: uname -a
47+
shell: bash
48+
49+
### Build Swift
50+
51+
- name: Copy preset
52+
working-directory: codeql-swift-prebuild
53+
bash: shell
54+
run: |
55+
cp codeql-swift-artifacts/swift-build-presets ~/.swift-build-presets
56+
57+
- name: Get swift version
58+
shell: bash
59+
run: |
60+
echo "SWIFT_TAG=$(cat codeql-swift-artifacts/swift_version.txt)" | tee -a $GITHUB_ENV
61+
62+
- name: Checkout Swift
63+
uses: actions/checkout@v3
64+
with:
65+
repository: apple/swift
66+
path: swift
67+
ref: ${{ env.SWIFT_TAG }}
68+
69+
- name: Checkout Swift dependencies
70+
working-directory: codeql-swift-prebuild
71+
shell: bash
72+
run: |
73+
swift/utils/update-checkout --clone --tag ${{ env.SWIFT_TAG }}
74+
75+
- name: Patch Swift
76+
working-directory: swift
77+
shell: bash
78+
run: |
79+
git apply $GITHUB_WORKSPACE/codeql-swift-artifacts/swift-build-system.patch
80+
81+
- uses: swift-actions/setup-swift@194625b58a582570f61cc707c3b558086c26b723
82+
if: runner.os == 'Linux'
83+
with:
84+
swift-version: 5.7.1
85+
86+
- name: Build
87+
working-directory: codeql-swift-prebuild
88+
shell: bash
89+
env:
90+
SKIP_XCODE_VERSION_CHECK: 1
91+
run: |
92+
swift/utils/build-script --preset=codeql
93+
94+
### Package
95+
96+
- name: Check build
97+
working-directory: codeql-swift-prebuild
98+
shell: bash
99+
run: |
100+
ls build
101+
ls build/codeql
102+
103+
- name: Package
104+
shell: bash
105+
working-directory: codeql-swift-prebuild
106+
run: |
107+
codeql-swift-artifacts/pkg_swift_llvm.py \
108+
--swift-source-tree swift \
109+
--llvm-build-tree build/codeql/llvm-* \
110+
--swift-build-tree build/codeql/swift-* \
111+
--output swift-prebuilt-${{ runner.os }}-${{ runner.arch }}
112+
ls
113+
file swift-prebuilt.*
114+
115+
### Upload Artifacts
116+
117+
- name: Upload pre-built artifacts
118+
uses: actions/upload-artifact@v3
119+
with:
120+
name: swift-prebuilt-${{ runner.os }}-${{ runner.arch }}
121+
path: swift-prebuilt-*

actions/release/action.yml

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
name: Publish prebuilt package artifacts
2+
description: Publish prebuilt package artifacts as a GitHub release
3+
4+
runs:
5+
using: composite
6+
steps:
7+
### For debugging
8+
9+
- name: Dump environment
10+
shell: bash
11+
env:
12+
GITHUB_CONTEXT: '${{ toJson(github.event) }}'
13+
run: env | sort
14+
15+
- name: Get swift version
16+
shell: bash
17+
run: |
18+
echo "SWIFT_TAG=$(cat codeql-swift-artifacts/swift_version.txt)" | tee -a $GITHUB_ENV
19+
20+
- name: Download all artifacts
21+
uses: actions/download-artifact@v3
22+
23+
- name: Publish CLI release
24+
shell: bash
25+
env:
26+
GITHUB_TOKEN: ${{ secrets.CI_TOKEN }}
27+
VERSION: ${{ env.SWIFT_TAG }}.${{ github.event.number }}
28+
run: |
29+
ls
30+
file swift-prebuilt-*/*
31+
32+
echo '```' > notes.txt
33+
echo _swift_prebuilt_version = "\"$VERSION.$GITHUB_RUN_NUMBER\"" >> notes.txt
34+
echo _swift_sha_map = "{" >> notes.txt
35+
find swift-prebuilt-*/*zip | \
36+
xargs sha256sum | \
37+
sed 's/ /-/g' | sed 's/\//-/g' | \
38+
awk -F- ' { print " \042" $5 "-" $6 "\042: \042" $1 "\042," } ' >> notes.txt
39+
echo '}' >> notes.txt
40+
echo '```' >> notes.txt
41+
42+
gh release create \
43+
${{ github.event_name == 'pull_request' && "--draft" }} \
44+
--notes-file notes.txt \
45+
--repo "dsp-testing/codeql-swift-artifacts" \
46+
--title "$VERSION.$GITHUB_RUN_NUMBER" \
47+
"$VERSION.$GITHUB_RUN_NUMBER" \
48+
swift-prebuilt-*/*.zip > comment.txt
49+
cat notes.txt >> comment.txt
50+
gh pr comment ${{ github.event.number }} --repo $GITHUB_REPOSITORY -F comment.txt

swift_tag.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
swift-5.7.1-RELEASE

0 commit comments

Comments
 (0)