-
-
Notifications
You must be signed in to change notification settings - Fork 739
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
CI: update workflows to use Azure Trusted Signing
Fixes #1778 Signed-off-by: Nicola Murino <[email protected]>
- Loading branch information
Showing
3 changed files
with
279 additions
and
160 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,6 +5,10 @@ on: | |
branches: [2.6.x] | ||
pull_request: | ||
|
||
permissions: | ||
id-token: write | ||
contents: read | ||
|
||
jobs: | ||
test-deploy: | ||
name: Test and deploy | ||
|
@@ -13,11 +17,6 @@ jobs: | |
matrix: | ||
go: ['1.22'] | ||
os: [ubuntu-latest, macos-latest] | ||
upload-coverage: [true] | ||
include: | ||
- go: '1.22' | ||
os: windows-latest | ||
upload-coverage: false | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
|
@@ -30,7 +29,6 @@ jobs: | |
go-version: ${{ matrix.go }} | ||
|
||
- name: Build for Linux/macOS x86_64 | ||
if: startsWith(matrix.os, 'windows-') != true | ||
run: | | ||
go build -trimpath -tags nopgxregisterdefaulttypes,disable_grpc_modules -ldflags "-s -w -X github.com/drakkan/sftpgo/v2/internal/version.commit=`git describe --always --abbrev=8 --dirty` -X github.com/drakkan/sftpgo/v2/internal/version.date=`date -u +%FT%TZ`" -o sftpgo | ||
cd tests/eventsearcher | ||
|
@@ -46,8 +44,83 @@ jobs: | |
if: startsWith(matrix.os, 'macos-') == true | ||
run: CGO_ENABLED=1 GOOS=darwin GOARCH=arm64 SDKROOT=$(xcrun --sdk macosx --show-sdk-path) go build -trimpath -tags nopgxregisterdefaulttypes,disable_grpc_modules -ldflags "-s -w -X github.com/drakkan/sftpgo/v2/internal/version.commit=`git describe --always --abbrev=8 --dirty` -X github.com/drakkan/sftpgo/v2/internal/version.date=`date -u +%FT%TZ`" -o sftpgo_arm64 | ||
|
||
- name: Build for Windows | ||
if: startsWith(matrix.os, 'windows-') | ||
- name: Run test cases using SQLite provider | ||
run: go test -v -tags nopgxregisterdefaulttypes,disable_grpc_modules -p 1 -timeout 15m ./... -coverprofile=coverage.txt -covermode=atomic | ||
|
||
- name: Upload coverage to Codecov | ||
uses: codecov/codecov-action@v5 | ||
with: | ||
file: ./coverage.txt | ||
fail_ci_if_error: false | ||
token: ${{ secrets.CODECOV_TOKEN }} | ||
|
||
- name: Run test cases using bolt provider | ||
run: | | ||
go test -v -tags nopgxregisterdefaulttypes,disable_grpc_modules -p 1 -timeout 2m ./internal/config -covermode=atomic | ||
go test -v -tags nopgxregisterdefaulttypes,disable_grpc_modules -p 1 -timeout 5m ./internal/common -covermode=atomic | ||
go test -v -tags nopgxregisterdefaulttypes,disable_grpc_modules -p 1 -timeout 5m ./internal/httpd -covermode=atomic | ||
go test -v -tags nopgxregisterdefaulttypes,disable_grpc_modules -p 1 -timeout 8m ./internal/sftpd -covermode=atomic | ||
go test -v -tags nopgxregisterdefaulttypes,disable_grpc_modules -p 1 -timeout 5m ./internal/ftpd -covermode=atomic | ||
go test -v -tags nopgxregisterdefaulttypes,disable_grpc_modules -p 1 -timeout 5m ./internal/webdavd -covermode=atomic | ||
go test -v -tags nopgxregisterdefaulttypes,disable_grpc_modules -p 1 -timeout 2m ./internal/telemetry -covermode=atomic | ||
go test -v -tags nopgxregisterdefaulttypes,disable_grpc_modules -p 1 -timeout 2m ./internal/mfa -covermode=atomic | ||
go test -v -tags nopgxregisterdefaulttypes,disable_grpc_modules -p 1 -timeout 2m ./internal/command -covermode=atomic | ||
env: | ||
SFTPGO_DATA_PROVIDER__DRIVER: bolt | ||
SFTPGO_DATA_PROVIDER__NAME: 'sftpgo_bolt.db' | ||
|
||
- name: Run test cases using memory provider | ||
run: go test -v -tags nopgxregisterdefaulttypes,disable_grpc_modules -p 1 -timeout 15m ./... -covermode=atomic | ||
env: | ||
SFTPGO_DATA_PROVIDER__DRIVER: memory | ||
SFTPGO_DATA_PROVIDER__NAME: '' | ||
|
||
- name: Prepare build artifact for macOS | ||
if: startsWith(matrix.os, 'macos-') == true | ||
run: | | ||
mkdir -p output/{init,bash_completion,zsh_completion} | ||
cp sftpgo output/sftpgo_x86_64 | ||
cp sftpgo_arm64 output/ | ||
cp sftpgo.json output/ | ||
cp -r templates output/ | ||
cp -r static output/ | ||
cp -r openapi output/ | ||
cp init/com.github.drakkan.sftpgo.plist output/init/ | ||
./sftpgo gen completion bash > output/bash_completion/sftpgo | ||
./sftpgo gen completion zsh > output/zsh_completion/_sftpgo | ||
./sftpgo gen man -d output/man/man1 | ||
gzip output/man/man1/* | ||
- name: Upload build artifact | ||
if: startsWith(matrix.os, 'ubuntu-') != true | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: sftpgo-${{ matrix.os }}-go-${{ matrix.go }} | ||
path: output | ||
|
||
test-deploy-windows: | ||
name: Test and deploy Windows | ||
environment: signing | ||
runs-on: windows-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 | ||
|
||
- name: Azure login | ||
uses: azure/login@v2 | ||
with: | ||
client-id: ${{ secrets.AZURE_CLIENT_ID }} | ||
tenant-id: ${{ secrets.AZURE_TENANT_ID }} | ||
subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }} | ||
|
||
- name: Set up Go | ||
uses: actions/setup-go@v5 | ||
with: | ||
go-version: '1.22' | ||
|
||
- name: Build | ||
run: | | ||
$GIT_COMMIT = (git describe --always --abbrev=8 --dirty) | Out-String | ||
$DATE_TIME = ([datetime]::Now.ToUniversalTime().toString("yyyy-MM-ddTHH:mm:ssZ")) | Out-String | ||
|
@@ -78,17 +151,31 @@ jobs: | |
Remove-Item Env:\GOOS | ||
Remove-Item Env:\GOARCH | ||
- name: Sign binaries | ||
uses: azure/[email protected] | ||
with: | ||
endpoint: https://eus.codesigning.azure.net/ | ||
trusted-signing-account-name: nicola | ||
certificate-profile-name: SFTPGo | ||
files: ${{ github.workspace }}\sftpgo.exe,${{ github.workspace }}\arm64\sftpgo.exe,${{ github.workspace }}\x86\sftpgo.exe | ||
files-folder-filter: exe,dll | ||
file-digest: SHA256 | ||
timestamp-rfc3161: http://timestamp.acs.microsoft.com | ||
timestamp-digest: SHA256 | ||
exclude-environment-credential: true | ||
exclude-workload-identity-credential: true | ||
exclude-managed-identity-credential: true | ||
exclude-shared-token-cache-credential: true | ||
exclude-visual-studio-credential: true | ||
exclude-visual-studio-code-credential: true | ||
exclude-azure-cli-credential: false | ||
exclude-azure-powershell-credential: true | ||
exclude-azure-developer-cli-credential: true | ||
exclude-interactive-browser-credential: true | ||
|
||
- name: Run test cases using SQLite provider | ||
run: go test -v -tags nopgxregisterdefaulttypes,disable_grpc_modules -p 1 -timeout 15m ./... -coverprofile=coverage.txt -covermode=atomic | ||
|
||
- name: Upload coverage to Codecov | ||
if: ${{ matrix.upload-coverage }} | ||
uses: codecov/codecov-action@v4 | ||
with: | ||
file: ./coverage.txt | ||
fail_ci_if_error: false | ||
token: ${{ secrets.CODECOV_TOKEN }} | ||
|
||
- name: Run test cases using bolt provider | ||
run: | | ||
go test -v -tags nopgxregisterdefaulttypes,disable_grpc_modules -p 1 -timeout 2m ./internal/config -covermode=atomic | ||
|
@@ -110,24 +197,14 @@ jobs: | |
SFTPGO_DATA_PROVIDER__DRIVER: memory | ||
SFTPGO_DATA_PROVIDER__NAME: '' | ||
|
||
- name: Prepare build artifact for macOS | ||
if: startsWith(matrix.os, 'macos-') == true | ||
- name: Initialize data provider | ||
run: | | ||
mkdir -p output/{init,bash_completion,zsh_completion} | ||
cp sftpgo output/sftpgo_x86_64 | ||
cp sftpgo_arm64 output/ | ||
cp sftpgo.json output/ | ||
cp -r templates output/ | ||
cp -r static output/ | ||
cp -r openapi output/ | ||
cp init/com.github.drakkan.sftpgo.plist output/init/ | ||
./sftpgo gen completion bash > output/bash_completion/sftpgo | ||
./sftpgo gen completion zsh > output/zsh_completion/_sftpgo | ||
./sftpgo gen man -d output/man/man1 | ||
gzip output/man/man1/* | ||
rm sftpgo.db | ||
./sftpgo initprovider | ||
shell: bash | ||
|
||
- name: Prepare Windows installer | ||
if: ${{ startsWith(matrix.os, 'windows-') && github.event_name != 'pull_request' }} | ||
- name: Prepare Windows installers | ||
if: ${{ github.event_name != 'pull_request' }} | ||
run: | | ||
Remove-Item -LiteralPath "output" -Force -Recurse -ErrorAction Ignore | ||
mkdir output | ||
|
@@ -146,15 +223,7 @@ jobs: | |
$REV_LIST=$LATEST_TAG+"..HEAD" | ||
$COMMITS_FROM_TAG= ((git rev-list $REV_LIST --count) | Out-String).Trim() | ||
$Env:SFTPGO_ISS_DEV_VERSION = $LATEST_TAG + "." + $COMMITS_FROM_TAG | ||
$CERT_PATH=(Get-Location -PSProvider FileSystem).ProviderPath + "\cert.pfx" | ||
[IO.File]::WriteAllBytes($CERT_PATH,[System.Convert]::FromBase64String($Env:CERT_DATA)) | ||
certutil -f -p "$Env:CERT_PASS" -importpfx MY "$CERT_PATH" | ||
rm "$CERT_PATH" | ||
& 'C:/Program Files (x86)/Windows Kits/10/bin/10.0.20348.0/x86/signtool.exe' sign /sm /tr http://timestamp.sectigo.com /td sha256 /fd sha256 /n "Nicola Murino" /d "SFTPGo" .\sftpgo.exe | ||
& 'C:/Program Files (x86)/Windows Kits/10/bin/10.0.20348.0/x86/signtool.exe' sign /sm /tr http://timestamp.sectigo.com /td sha256 /fd sha256 /n "Nicola Murino" /d "SFTPGo" .\arm64\sftpgo.exe | ||
& 'C:/Program Files (x86)/Windows Kits/10/bin/10.0.20348.0/x86/signtool.exe' sign /sm /tr http://timestamp.sectigo.com /td sha256 /fd sha256 /n "Nicola Murino" /d "SFTPGo" .\x86\sftpgo.exe | ||
$INNO_S='/Ssigntool=$qC:/Program Files (x86)/Windows Kits/10/bin/10.0.20348.0/x86/signtool.exe$q sign /sm /tr http://timestamp.sectigo.com /td sha256 /fd sha256 /n $qNicola Murino$q /d $qSFTPGo$q $f' | ||
iscc "$INNO_S" .\windows-installer\sftpgo.iss | ||
iscc .\windows-installer\sftpgo.iss | ||
rm .\output\sftpgo.exe | ||
rm .\output\sftpgo.db | ||
|
@@ -166,40 +235,57 @@ jobs: | |
Remove-Item Env:\SFTPGO_DATA_PROVIDER__DRIVER | ||
Remove-Item Env:\SFTPGO_DATA_PROVIDER__NAME | ||
$Env:SFTPGO_ISS_ARCH='arm64' | ||
iscc "$INNO_S" .\windows-installer\sftpgo.iss | ||
iscc .\windows-installer\sftpgo.iss | ||
rm .\output\sftpgo.exe | ||
copy .\x86\sftpgo.exe .\output | ||
$Env:SFTPGO_ISS_ARCH='x86' | ||
iscc "$INNO_S" .\windows-installer\sftpgo.iss | ||
certutil -delstore MY "Nicola Murino" | ||
env: | ||
CERT_DATA: ${{ secrets.CERT_DATA }} | ||
CERT_PASS: ${{ secrets.CERT_PASS }} | ||
iscc .\windows-installer\sftpgo.iss | ||
- name: Sign installers | ||
uses: azure/[email protected] | ||
with: | ||
endpoint: https://eus.codesigning.azure.net/ | ||
trusted-signing-account-name: nicola | ||
certificate-profile-name: SFTPGo | ||
files: ${{ github.workspace }}\sftpgo_windows_x86_64.exe,${{ github.workspace }}\sftpgo_windows_arm64.exe,${{ github.workspace }}\sftpgo_windows_x86.exe | ||
files-folder-filter: exe,dll | ||
file-digest: SHA256 | ||
timestamp-rfc3161: http://timestamp.acs.microsoft.com | ||
timestamp-digest: SHA256 | ||
exclude-environment-credential: true | ||
exclude-workload-identity-credential: true | ||
exclude-managed-identity-credential: true | ||
exclude-shared-token-cache-credential: true | ||
exclude-visual-studio-credential: true | ||
exclude-visual-studio-code-credential: true | ||
exclude-azure-cli-credential: false | ||
exclude-azure-powershell-credential: true | ||
exclude-azure-developer-cli-credential: true | ||
exclude-interactive-browser-credential: true | ||
|
||
- name: Upload Windows installer x86_64 artifact | ||
if: ${{ startsWith(matrix.os, 'windows-') && github.event_name != 'pull_request' }} | ||
if: ${{ github.event_name != 'pull_request' }} | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: sftpgo_windows_installer_x86_64 | ||
path: ./sftpgo_windows_x86_64.exe | ||
|
||
- name: Upload Windows installer arm64 artifact | ||
if: ${{ startsWith(matrix.os, 'windows-') && github.event_name != 'pull_request' }} | ||
if: ${{ github.event_name != 'pull_request' }} | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: sftpgo_windows_installer_arm64 | ||
path: ./sftpgo_windows_arm64.exe | ||
|
||
- name: Upload Windows installer x86 artifact | ||
if: ${{ startsWith(matrix.os, 'windows-') && github.event_name != 'pull_request' }} | ||
if: ${{ github.event_name != 'pull_request' }} | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: sftpgo_windows_installer_x86 | ||
path: ./sftpgo_windows_x86.exe | ||
|
||
- name: Prepare build artifact for Windows | ||
if: startsWith(matrix.os, 'windows-') | ||
run: | | ||
Remove-Item -LiteralPath "output" -Force -Recurse -ErrorAction Ignore | ||
mkdir output | ||
|
@@ -218,10 +304,9 @@ jobs: | |
xcopy .\openapi .\output\openapi\ /E | ||
- name: Upload build artifact | ||
if: startsWith(matrix.os, 'ubuntu-') != true | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: sftpgo-${{ matrix.os }}-go-${{ matrix.go }} | ||
name: sftpgo-windows-portable | ||
path: output | ||
|
||
test-build-flags: | ||
|
@@ -524,4 +609,5 @@ jobs: | |
- name: Run golangci-lint | ||
uses: golangci/golangci-lint-action@v6 | ||
with: | ||
args: --timeout=10m | ||
version: latest |
Oops, something went wrong.