Skip to content

Commit 9c9edda

Browse files
committed
restructure automation for releases
1 parent 8b5f3a6 commit 9c9edda

File tree

4 files changed

+126
-48
lines changed

4 files changed

+126
-48
lines changed
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
name: Build Release (Linux x64)
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
version:
7+
description: |
8+
The version to release. (eg: 0.1.2, exclude the 'v'.).
9+
required: true
10+
type: string
11+
12+
13+
jobs:
14+
build-linux64:
15+
runs-on: ubuntu-latest
16+
17+
steps:
18+
- uses: actions/checkout@v3
19+
- name: Setup .NET
20+
uses: actions/setup-dotnet@v3
21+
with:
22+
dotnet-version: 6.0.x
23+
- name: Restore dependencies
24+
run: dotnet restore
25+
- name: Build
26+
run: dotnet build -c Release --no-restore
27+
28+
- name: Build Bundle (Linux)
29+
shell: bash
30+
run: |
31+
echo "Current Directory $(pwd)"
32+
# build the project
33+
dotnet publish ./src/CodeQLToolkit.Core/CodeQLToolkit.Core.csproj /p:PublishProfile=./src/CodeQLToolkit.Core/Properties/PublishProfiles/Linux-Profile.pubxml
34+
cp ./src/CodeQLToolkit.Core/bin/Release/net6.0/publish/linux-x64/CodeQLToolkit.Core ./src/CodeQLToolkit.Core/bin/Release/net6.0/publish/linux-x64/qlt
35+
36+
# repair permissions
37+
chmod +x ./src/CodeQLToolkit.Core/bin/Release/net6.0/publish/linux-x64/qlt
38+
chmod +r -R ./src/CodeQLToolkit.Core/bin/Release/net6.0/publish/linux-x64
39+
40+
# create bundle
41+
ARCHIVE="$(pwd)/qlt-linux-x86_64.zip"
42+
pushd ./src/CodeQLToolkit.Core/bin/Release/net6.0/publish/linux-x64
43+
zip -r $ARCHIVE .
44+
popd
45+
46+
- name: Upload build artifacts
47+
uses: actions/upload-artifact@v3
48+
with:
49+
name: qlt-dist
50+
path: qlt*.zip
51+
52+
- name: Upload Build Artifacts
53+
shell: pwsh
54+
run: |
55+
Write-Host (Get-Location)
56+
gh release upload ${{inputs.version}} ./qlt-linux-x86_64.zip
57+
env:
58+
GH_TOKEN: ${{ github.token }}
Lines changed: 16 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1,56 +1,29 @@
1-
name: Build Release
1+
name: Build and Publish Release
22

33
on:
44
workflow_dispatch:
5+
inputs:
6+
version:
7+
description: |
8+
The version to release. (eg: 0.1.2, exclude the 'v'.).
9+
required: true
10+
type: string
511

612
jobs:
7-
build:
8-
runs-on: ubuntu-latest
9-
13+
create-draft-release:
14+
runs-on: ubuntu-latest
1015
steps:
11-
- uses: actions/checkout@v3
12-
- name: Setup .NET
13-
uses: actions/setup-dotnet@v3
14-
with:
15-
dotnet-version: 6.0.x
16-
- name: Restore dependencies
17-
run: dotnet restore
18-
- name: Build
19-
run: dotnet build -c Release --no-restore
20-
# - name: Test
21-
# run: dotnet test --no-build --verbosity normal
22-
23-
# create archive in \src\CodeQLToolkit.Core\bin\Release\net6.0\publish\linux-x64
24-
- name: Build Bundle (Linux)
25-
shell: bash
26-
run: |
27-
echo "Current Directory $(pwd)"
28-
# build the project
29-
dotnet publish ./src/CodeQLToolkit.Core/CodeQLToolkit.Core.csproj /p:PublishProfile=./src/CodeQLToolkit.Core/Properties/PublishProfiles/Linux-Profile.pubxml
30-
cp ./src/CodeQLToolkit.Core/bin/Release/net6.0/publish/linux-x64/CodeQLToolkit.Core ./src/CodeQLToolkit.Core/bin/Release/net6.0/publish/linux-x64/qlt
31-
32-
# repair permissions
33-
chmod +x ./src/CodeQLToolkit.Core/bin/Release/net6.0/publish/linux-x64/qlt
34-
chmod +r -R ./src/CodeQLToolkit.Core/bin/Release/net6.0/publish/linux-x64
35-
36-
# create bundle
37-
ARCHIVE="$(pwd)/qlt-linux-x86_64.zip"
38-
pushd ./src/CodeQLToolkit.Core/bin/Release/net6.0/publish/linux-x64
39-
zip -r $ARCHIVE .
40-
popd
41-
42-
- name: Upload build artifacts
43-
uses: actions/upload-artifact@v3
44-
with:
45-
name: qlt-dist
46-
path: qlt*.zip
4716

4817
- name: Create Draft Release
4918
shell: pwsh
5019
run: |
5120
Write-Host (Get-Location)
52-
New-Item -ItemType "directory" -Path . -Name "artifacts"
53-
Move-Item qlt-linux-x86_64.zip artifacts\
54-
.\scripts\create_draft_release.ps1 -ArchiveDir (Get-Item "artifacts").FullName
21+
.\scripts\create_draft_release.ps1 -Version ${{inputs.version}}
5522
env:
5623
GH_TOKEN: ${{ github.token }}
24+
25+
build-linux64:
26+
uses: ./.github/workflows/internal-build-release-linux64.yml
27+
needs: create-draft-release
28+
with:
29+
version: ${{inputs.version}}

scripts/build_codeql_bundle_dist.ps1

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
param(
2+
[Parameter(Mandatory=$true)]
3+
[string]
4+
$Version,
5+
[Parameter(Mandatory=$true)]
6+
[string]
7+
$OutputDirectory
8+
)
9+
10+
11+
# create output directory if it doesn't exist
12+
if (-not (Test-Path $OutputDirectory)) {
13+
New-Item -ItemType Directory -Path $OutputDirectory | Out-Null
14+
}
15+
16+
# download a copy of the release from GitHub
17+
gh release download "v$Version" --repo https://github.com/rvermeulen/codeql-bundle -D $OutputDirectory -A zip
18+
19+
# extract the zip file
20+
Expand-Archive -Path "$OutputDirectory\codeql-bundle-$Version.zip" -DestinationPath $OutputDirectory
21+
22+
# creates a directory named `codeql-bundle-<version>`
23+
$ArchiveDirectory = Join-Path $OutputDirectory "codeql-bundle-$Version"
24+
25+
Push-Location $ArchiveDirectory
26+
27+
# at this point python should already be installed as well as poetry
28+
# export the requirements
29+
poetry export -f requirements.txt > requirements.txt
30+
31+
# install the requirements
32+
pip install -r requirements.txt
33+
34+
Push-Location "codeql_bundle"
35+
36+
# pyinstaller should also be installed
37+
pyinstaller -F -n codeql_bundle cli.py
38+
39+
40+
Pop-Location
41+
Pop-Location
42+
43+
$OutputFile = Join-Path $ArchiveDirectory "codeql_bundle" "dist" "codeql_bundle.exe"
44+
45+
# this will output the binary in the `dist` directory - we should copy that binary the toplevel directory.
46+
Copy-Item -Path $OutputFile -Destination $OutputDirectory
47+
48+

scripts/create_draft_release.ps1

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,12 @@ param(
44
$Version,
55
[Parameter(Mandatory=$false)]
66
[string]
7-
$Branch = "master",
8-
[Parameter(Mandatory=$true)]
7+
$Branch = "main",
8+
[Parameter(Mandatory=$false)]
99
[string]
1010
$ArchiveDir
1111
)
1212

13-
$VERSION_FILE = Join-Path "src" "CodeQLToolkit.Core" "ver.txt"
1413

1514
if (-not $Version) {
1615
Write-Host "Detecting version from version file..."
@@ -20,7 +19,7 @@ if (-not $Version) {
2019
Write-Host "Creating draft release for version $Version on branch $Branch..."
2120

2221
# create checksums
23-
Get-FileHash -Algorithm SHA256 $ArchiveDir/* | ForEach-Object { (Get-Item $_.Path).Name + " (SHA256): " + $_.Hash } | Out-File -Path $ArchiveDir/checksums.txt
22+
#Get-FileHash -Algorithm SHA256 $ArchiveDir/* | ForEach-Object { (Get-Item $_.Path).Name + " (SHA256): " + $_.Hash } | Out-File -Path $ArchiveDir/checksums.txt
2423

25-
gh release create "v$Version" -d --target "$Branch" -t "v$Version" $ArchiveDir/*
24+
gh release create "v$Version" -d --target "$Branch" -t "v$Version" # $ArchiveDir/*
2625

0 commit comments

Comments
 (0)