-
Notifications
You must be signed in to change notification settings - Fork 0
143 lines (117 loc) · 4.04 KB
/
release.yml
File metadata and controls
143 lines (117 loc) · 4.04 KB
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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
name: Build and Publish Extractor Pack
on:
push:
branches: ["main"]
workflow_dispatch:
permissions:
contents: write
packages: write
jobs:
release-check:
runs-on: ubuntu-latest
outputs:
release: ${{ steps.get_version.outputs.release }}
version: ${{ steps.get_version.outputs.version }}
steps:
- uses: actions/checkout@v4
- name: "Check release version"
id: get_version
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
set -e
pip install yq
current_version=$(cat .release.yml | yq -r ".version")
released_version=$(gh api -H "Accept: application/vnd.github+json" -H "X-GitHub-Api-Version: 2022-11-28" /repos/:owner/:repo/releases/latest | jq -r ".tag_name")
if [[ "$current_version" == "NA" || "$current_version" == "$released_version" ]]; then
echo "No new release found"
echo "release=false" >> "$GITHUB_OUTPUT"
else
echo "New release found"
echo "version=$current_version" >> "$GITHUB_OUTPUT"
echo "release=true" >> "$GITHUB_OUTPUT"
fi
compile:
name: "Compile Extractor Pack for ${{ matrix.os }}"
needs: [release-check]
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
# TODO: Add windows-latest
os: [ubuntu-latest, macos-latest]
if: ${{ needs.release-check.outputs.release == 'true' }}
steps:
- name: "Checkout"
uses: actions/checkout@v4
with:
submodules: true
- name: "Set up Rust"
uses: dtolnay/rust-toolchain@nightly
if: ${{ matrix.os != 'windows-latest' }}
- name: "Build Extractor"
if: ${{ matrix.os != 'windows-latest' }}
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: ./scripts/create-extractor-pack.sh
- name: "Upload bundle artifact"
uses: actions/upload-artifact@v4
with:
name: "extractor-bundle-${{ matrix.os }}"
path: "./extractor-pack"
bundle:
name: "Bundle Extractor Pack"
runs-on: ubuntu-latest
needs: [compile]
if: ${{ needs.release-check.outputs.release == 'true' }}
steps:
- name: "Checkout"
uses: actions/checkout@v4
with:
submodules: true
- name: "Downloadd all artifacts"
uses: actions/download-artifact@v4
with:
path: "./extractor-pack"
merge-multiple: true
- name: "Publish Extractor Pack"
if: github.ref == 'refs/heads/main'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
EXTRACTOR_NAME: "bicep"
run: |
./scripts/publish-extractor-pack.sh
queries:
runs-on: ubuntu-latest
needs: [release-check]
if: ${{ needs.release-check.outputs.release == 'true' }}
permissions:
contents: read
packages: write
strategy:
fail-fast: false
matrix:
packs: ["lib", "src"]
steps:
- name: "Checkout"
uses: actions/checkout@v4
- name: "Check and Publish CodeQL Packs"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
PACKS: ${{ matrix.packs }}
ORG: ${{ github.repository_owner }}
run: |
set -e
PACK_PATH="ql/${PACKS}/qlpack.yml"
echo "[+] Pack Path :: $PACK_PATH"
CURRENT_VERSION=$(grep version $PACK_PATH | awk '{print $2}')
PACK_FULLNAME=$(cat $PACK_PATH | grep "name:" | awk '{print $2}')
PACK_NAME=$(echo $PACK_FULLNAME | awk -F '/' '{print $2}')
echo "[+] Pack Name :: $PACK_NAME ($PACK_FULLNAME)"
PUBLISHED_VERSION=$(gh api /orgs/${ORG}/packages/container/$PACK_NAME/versions --jq '.[0].metadata.container.tags[0]')
echo "Packs :: ${CURRENT_VERSION} -> ${PUBLISHED_VERSION}"
if [ "$PUBLISHED_VERSION" != "$CURRENT_VERSION" ]; then
gh extension install github/gh-codeql
gh codeql pack install "ql/${PACKS}"
gh codeql pack publish "ql/${PACKS}"
fi