Skip to content

Commit a42430d

Browse files
committed
Actions: Add workflow to publish packages
1 parent 8195ebf commit a42430d

File tree

2 files changed

+104
-3
lines changed

2 files changed

+104
-3
lines changed
Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,29 @@
11
name: Fetch CodeQL
22
description: Fetches the latest version of CodeQL
3+
inputs:
4+
use-bundle:
5+
description: Set to `true` to download the CodeQL CLI bundle that also includes compiled queries.
6+
default: 'false'
7+
required: false
8+
39
runs:
410
using: composite
511
steps:
612
- name: Fetch CodeQL
713
shell: bash
814
run: |
9-
LATEST=$(gh release list --repo https://github.com/github/codeql-cli-binaries | cut -f 1 | grep -v beta | sort --version-sort | tail -1)
10-
gh release download --repo https://github.com/github/codeql-cli-binaries --pattern codeql-linux64.zip "$LATEST"
11-
unzip -q -d "${RUNNER_TEMP}" codeql-linux64.zip
15+
LATEST=$(gh release list --repo $REPO | cut -f 3 | grep -v beta | sort --version-sort | tail -1)
16+
gh release download --repo $REPO --pattern "$PATTERN" "$LATEST"
17+
18+
if [ "$USE_BUNDLE" == 'true' ]; then
19+
tar -xzf "$PATTERN" -C "${RUNNER_TEMP}"
20+
else
21+
unzip -q -d "${RUNNER_TEMP}" "$PATTERN"
22+
fi
1223
echo "${RUNNER_TEMP}/codeql" >> "${GITHUB_PATH}"
1324
env:
1425
GITHUB_TOKEN: ${{ github.token }}
26+
USE_BUNDLE: '${{ inputs.use-bundle == ''true'' }}'
27+
REPO: '${{ inputs.use-bundle == ''true'' && ''https://github.com/dsp-testing/codeql-cli-nightlies'' || ''https://github.com/github/codeql-cli-binaries''}}'
28+
# REPO: '${{ inputs.use-bundle == ''true'' && ''https://github.com/github/codeql-action'' || ''https://github.com/github/codeql-cli-binaries''}}'
29+
PATTERN: '${{ inputs.use-bundle == ''true'' && ''codeql-bundle-linux64.tar.gz'' || ''codeql-linux64.zip''}}'
Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
# Publishes the core libraries to the CodeQL package registry.
2+
name: Publish CodeQL core libraries
3+
on:
4+
pull_request:
5+
paths:
6+
- '.github/workflows/pack-publisher.yml' # for testing changes to this workflow
7+
8+
workflow_dispatch:
9+
# the cli to use, or blank to build it again
10+
# the pre-built packs, or blank to build again
11+
inputs:
12+
packages-build-number:
13+
description: |
14+
A CodeQL CLI workflow run number to download the packages artifacts from.
15+
Leave blank to build packages from this repository.
16+
default: ''
17+
required: false
18+
19+
permissions:
20+
contents: write
21+
22+
jobs:
23+
codeql-package-publish:
24+
environment: codeql-package-publish
25+
name: CodeQL Package - Publish
26+
runs-on: ubuntu-20.04
27+
28+
steps:
29+
- name: Dump environment
30+
run: env
31+
- name: Dump GitHub event context
32+
env:
33+
GITHUB_CONTEXT: '${{ toJson(github.event) }}'
34+
run: echo "$GITHUB_CONTEXT"
35+
36+
- name: Checkout repository
37+
uses: actions/checkout@v2
38+
39+
# TODO add a way to specify different versions of the CLI
40+
- name: Download CLI
41+
uses: ./.github/actions/fetch-codeql
42+
with:
43+
use-bundle: 'true'
44+
45+
- name: Publish packs
46+
run: |
47+
set -exu
48+
# do not publish go or suite-helpers
49+
# `ls` all directories in the bundle remove suite-helpers and go
50+
PACK_FOLDERS_TO_PUBLISH="$(ls -d $RUNNER_TEMP/codeql/qlpacks/codeql/*/* | grep -v suite | grep -v "\-go")"
51+
ARCHIVES="$RUNNER_TEMP/archives"
52+
53+
mkdir -p "$ARCHIVES"
54+
55+
echo "Running on: $PACK_FOLDERS_TO_PUBLISH"
56+
57+
# tgz each folder
58+
# then run pack publish on it
59+
for folder in $PACK_FOLDERS_TO_PUBLISH
60+
do
61+
echo "Archiving $folder for publishing"
62+
tar cfz "$ARCHIVES/archive.tgz" -C "$folder" .
63+
echo "Publishing $ARCHIVES/archive.tgz"
64+
echo "Would have run: 'codeql pack publish --file "$ARCHIVES/archive.tgz"'"
65+
done
66+
67+
- name: Bump versions
68+
run: |
69+
echo "Would have run 'codeql pack release'"
70+
71+
- name: Update git config
72+
run: |
73+
git config --global user.email "[email protected]"
74+
git config --global user.name "github-actions[bot]"
75+
76+
- name: Create PR
77+
run: |
78+
git add .
79+
git commit -m "Post-release preparation"
80+
NEW_BRANCH="post-release-prep-$(git show -s --format=%h)"
81+
git checkout -b $NEW_BRANCH
82+
gh pr create
83+
--head "$NEW_BRANCH" \
84+
--base "$GITHUB_BASE_REF" \
85+
--fill
86+
--draft

0 commit comments

Comments
 (0)