Skip to content

Commit 3f39af2

Browse files
committed
workflow to automatically bump cli version if different from the current version
1 parent bce5d42 commit 3f39af2

2 files changed

Lines changed: 53 additions & 0 deletions

File tree

.github/workflows/bump-cli.yml

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
name: Bump CLI version
2+
on:
3+
push:
4+
branches: [main]
5+
pull_request:
6+
branches: [main]
7+
schedule:
8+
- cron: 0 0 */14 * * # run every 14 days
9+
10+
jobs:
11+
build:
12+
name: Build
13+
runs-on: ubuntu-latest
14+
steps:
15+
- name: Checkout
16+
uses: actions/checkout@v3
17+
with:
18+
fetch-depth: 1
19+
token: ${{ secrets.WORKFLOW_TOKEN }}
20+
- name: Install dependencies
21+
run: |
22+
sudo apt-get update
23+
sudo apt-get install -qq jq
24+
sudo apt-get install gh
25+
shell: bash
26+
- name: Bump CLI
27+
env:
28+
GH_TOKEN: ${{ github.token }}
29+
run: |
30+
scripts/replace-cli-version.sh
31+
- name: Push changes to a branch
32+
env:
33+
GH_TOKEN: ${{ secrets.WORKFLOW_TOKEN }}
34+
run: |
35+
git config user.name github-actions
36+
git config user.email github-actions@github.com
37+
git checkout -b bump-cli
38+
if [[ `git status --porcelain` ]]; then
39+
git add .
40+
git commit -m "automatically bump cli version"
41+
git push --set-upstream origin bump-cli
42+
git push
43+
gh pr create --title "Bump CLI Version for integration tests" --body ""
44+
fi

scripts/replace-cli-version.sh

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#!/bin/bash
2+
3+
VERSIONS=$(gh api -H "Accept: application/vnd.github+json" /repos/github/codeql-cli-binaries/releases | jq '.[].tag_name' | head -2)
4+
5+
LATEST_VERSION=$(echo $VERSIONS | awk '{ print $1 }' | sed "s/\"//g")
6+
PREVIOUS_VERSION=$(echo $VERSIONS | awk '{ print $2 }' | sed "s/\"//g")
7+
8+
sed -i "s/$PREVIOUS_VERSION/$LATEST_VERSION/g" .github/workflows/main.yml
9+
sed -i "s/$PREVIOUS_VERSION/$LATEST_VERSION/g" extensions/ql-vscode/src/vscode-tests/ensureCli.ts

0 commit comments

Comments
 (0)