Skip to content

Commit 6533074

Browse files
ci(build): add linux release automation and release automation validation
Signed-off-by: Swapnanil Gupta <[email protected]>
1 parent 29f81de commit 6533074

12 files changed

+632
-149
lines changed

.github/workflows/build-and-test-msi.yaml

Lines changed: 22 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,19 @@ on:
55
workflow_dispatch:
66
inputs:
77
ref_name:
8-
description: "name of git ref for which to build installer"
8+
description: "the ref (tag/branch) to use to extract tag/version"
99
required: true
1010
type: string
1111
workflow_call:
1212
inputs:
1313
ref_name:
14+
description: "the ref (tag/branch) to use to extract tag/version"
1415
required: true
1516
type: string
17+
version:
18+
description: "override for version, will be used instead of ref if set, used for testing"
19+
required: false
20+
type: string
1621
schedule:
1722
- cron: '0 9 * * *'
1823
env:
@@ -28,43 +33,11 @@ permissions:
2833
jobs:
2934
get-tag-name:
3035
name: Get tag name
31-
runs-on: ubuntu-latest
32-
timeout-minutes: 2
33-
outputs:
34-
tag: ${{ steps.check-tag.outputs.tag }}
35-
version: ${{ steps.check-tag.outputs.version }}
36-
commit: ${{ steps.export-commit.outputs.commit }}
37-
steps:
38-
- name: Check tag from workflow input and github ref
39-
id: check-tag
40-
run: |
41-
if [ -n "${{ inputs.ref_name }}" ]; then
42-
tag=${{ inputs.ref_name }}
43-
else
44-
tag=${{ github.ref_name }}
45-
fi
46-
echo "tag=$tag" >> ${GITHUB_OUTPUT}
47-
48-
version=${tag#v}
49-
if [[ $version =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
50-
echo "Version matches format: $version"
51-
else
52-
echo "Version $version doesn't match format. Using test version: 0.0.1"
53-
version="0.0.1"
54-
fi
55-
echo "version=$version" >> ${GITHUB_OUTPUT}
56-
- uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
57-
with:
58-
ref: ${{ steps.check-tag.outputs.tag }}
59-
fetch-depth: 0
60-
persist-credentials: false
61-
submodules: true
62-
- name: Export commit hash
63-
id: export-commit
64-
run: |
65-
commit=$(git rev-parse HEAD)
66-
echo "commit=$commit" >> ${GITHUB_OUTPUT}
67-
36+
uses: ./.github/workflows/get-version-and-tag-for-ref.yaml
37+
with:
38+
ref_name: ${{ inputs.ref_name }}
39+
version: ${{ inputs.version }}
40+
6841
windows-msi-build:
6942
needs: get-tag-name
7043
runs-on: [self-hosted, windows, amd64, release]
@@ -91,7 +64,7 @@ jobs:
9164
cache: false
9265
- uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
9366
with:
94-
ref: ${{ needs.get-tag-name.outputs.commit }}
67+
ref: ${{ needs.get-tag-name.outputs.tag }}
9568
fetch-depth: 0
9669
persist-credentials: false
9770
submodules: recursive
@@ -114,20 +87,22 @@ jobs:
11487
cd deps/finch-core && make clean
11588
- name: Build project
11689
run: |
90+
$dirty_tag = git describe --match 'v[0-9]*' --dirty='.modified' --always --tags
91+
Write-Host "dirty tag: $dirty_tag"
11792
make FINCH_OS_IMAGE_LOCATION_ROOT=__INSTALLFOLDER__
11893
- name: generate and download signed msi
11994
run: |
12095
$version="${{ needs.get-tag-name.outputs.version }}"
12196
$tag="${{ needs.get-tag-name.outputs.tag }}"
12297
powershell .\msi-builder\BuildFinchMSI.ps1 -Version $version
12398
$timestamp=[math]::truncate((Get-Date (Get-Date).ToUniversalTime() -UFormat "%s"))
124-
$unsignedMSI="Finch-$tag-$timestamp.msi"
99+
$unsignedMSI="Finch-$version-$timestamp.msi"
125100
Write-Host "Upload unsigned MSI: $unsignedMSI"
126-
101+
127102
aws s3 cp "./msi-builder/build/Finch-$version.msi" "${{ secrets.WINDOWS_UNSIGNED_BUCKET }}$unsignedMSI" --acl bucket-owner-full-control --no-progress
128103
New-Item -Path "./msi-builder/build/signed/" -ItemType Directory -Force
129104
130-
Write-Host "Attemp to download signed MSI"
105+
Write-Host "Attempt to download signed MSI"
131106
$retryCount = 0
132107
$maxRetries = 20
133108
$delay = 5
@@ -137,7 +112,7 @@ jobs:
137112
$signedMSI = aws s3 ls ${{ secrets.WINDOWS_SIGNED_BUCKET }} 2>&1 | Where-Object { $_ -match "$unsignedMSI" } | Sort-Object -Descending | Select-Object -First 1 | ForEach-Object { ($_ -split '\s+')[-1] }
138113
if ($signedMSI -and ($signedMSI -notlike "*An error occurred (404) when calling the HeadObject operation*")) {
139114
try {
140-
aws s3 cp "${{ secrets.WINDOWS_SIGNED_BUCKET }}$signedMSI" "./msi-builder/build/signed/Finch-$tag.msi"
115+
aws s3 cp "${{ secrets.WINDOWS_SIGNED_BUCKET }}$signedMSI" "./msi-builder/build/signed/Finch-$version.msi"
141116
break
142117
} catch {
143118
Write-Host "Error during copy: $_"
@@ -159,8 +134,8 @@ jobs:
159134
aws-region: ${{ secrets.REGION }}
160135
- name: upload signed MSI to S3
161136
run: |
162-
$tag="${{ needs.get-tag-name.outputs.tag }}"
163-
aws s3 cp "./msi-builder/build/signed/Finch-$tag.msi" "s3://${{ secrets.INSTALLER_PRIVATE_BUCKET_NAME }}/Finch-$tag.msi" --no-progress
137+
$version="${{ needs.get-tag-name.outputs.version }}"
138+
aws s3 cp "./msi-builder/build/signed/Finch-$version.msi" "s3://${{ secrets.INSTALLER_PRIVATE_BUCKET_NAME }}/Finch-$version.msi" --no-progress
164139
- name: Remove Finch VM and Clean Up Previous Environment
165140
if: ${{ always() }}
166141
timeout-minutes: 5
@@ -235,8 +210,8 @@ jobs:
235210
}
236211
- name: Download MSI from S3
237212
run: |
238-
$tag="${{ needs.get-tag-name.outputs.tag }}"
239-
aws s3 cp "s3://${{ secrets.INSTALLER_PRIVATE_BUCKET_NAME }}/Finch-$tag.msi" ./Finch.msi
213+
$version="${{ needs.get-tag-name.outputs.version }}"
214+
aws s3 cp "s3://${{ secrets.INSTALLER_PRIVATE_BUCKET_NAME }}/Finch-$version.msi" ./Finch.msi
240215
- name: Install MSI silently
241216
run: |
242217
Start-Process 'Finch.msi' -ArgumentList '/quiet' -Wait

.github/workflows/build-and-test-pkg.yaml

Lines changed: 14 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,19 @@ on:
55
workflow_dispatch:
66
inputs:
77
ref_name:
8-
description: "name of git ref for which to build installer"
8+
description: "the ref (tag/branch) to use to extract tag/version"
99
required: true
1010
type: string
1111
workflow_call:
1212
inputs:
1313
ref_name:
14+
description: "the ref (tag/branch) to use to extract tag/version"
1415
required: true
1516
type: string
17+
version:
18+
description: "override for version, will be used instead of ref if set, used for testing"
19+
required: false
20+
type: string
1621
schedule:
1722
- cron: '0 9 * * *'
1823
env:
@@ -28,36 +33,10 @@ permissions:
2833
jobs:
2934
get-tag-name:
3035
name: Get tag name
31-
runs-on: ubuntu-latest
32-
permissions:
33-
contents: read
34-
timeout-minutes: 2
35-
outputs:
36-
tag: ${{ steps.check-tag.outputs.tag }}
37-
commit: ${{ steps.export-commit.outputs.commit }}
38-
steps:
39-
- name: Check tag from workflow input and github ref
40-
id: check-tag
41-
run: |
42-
if [ -n "${{ inputs.ref_name }}" ]; then
43-
tag=${{ inputs.ref_name }}
44-
else
45-
tag=${{ github.ref_name }}
46-
fi
47-
echo "using tag=${tag}"
48-
echo "tag=$tag" >> ${GITHUB_OUTPUT}
49-
- uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
50-
with:
51-
ref: ${{ steps.check-tag.outputs.tag }}
52-
fetch-depth: 0
53-
persist-credentials: false
54-
submodules: true
55-
- name: Export commit hash
56-
id: export-commit
57-
run: |
58-
commit=$(git rev-parse HEAD)
59-
echo "using commit=${commit}"
60-
echo "commit=$commit" >> ${GITHUB_OUTPUT}
36+
uses: ./.github/workflows/get-version-and-tag-for-ref.yaml
37+
with:
38+
ref_name: ${{ inputs.ref_name }}
39+
version: ${{ inputs.version }}
6140

6241
macos-aarch64-pkg-build:
6342
needs: get-tag-name
@@ -75,7 +54,7 @@ jobs:
7554
output_arch: aarch64
7655
version: 14
7756
tag: ${{ needs.get-tag-name.outputs.tag }}
78-
commit: ${{ needs.get-tag-name.outputs.commit }}
57+
finch_version: ${{ needs.get-tag-name.outputs.version }}
7958

8059
macos-x86-64-pkg-build:
8160
needs: get-tag-name
@@ -93,7 +72,7 @@ jobs:
9372
output_arch: x86_64
9473
version: 14
9574
tag: ${{ needs.get-tag-name.outputs.tag }}
96-
commit: ${{ needs.get-tag-name.outputs.commit }}
75+
finch_version: ${{ needs.get-tag-name.outputs.version }}
9776

9877
macos-aarch64-pkg-test:
9978
strategy:
@@ -117,7 +96,7 @@ jobs:
11796
output_arch: aarch64
11897
version: ${{ matrix.version }}
11998
tag: ${{ needs.get-tag-name.outputs.tag }}
120-
commit: ${{ needs.get-tag-name.outputs.commit }}
99+
finch_version: ${{ needs.get-tag-name.outputs.version }}
121100

122101
macos-x86-64-pkg-test:
123102
strategy:
@@ -141,4 +120,4 @@ jobs:
141120
output_arch: x86_64
142121
version: ${{ matrix.version }}
143122
tag: ${{ needs.get-tag-name.outputs.tag }}
144-
commit: ${{ needs.get-tag-name.outputs.commit }}
123+
finch_version: ${{ needs.get-tag-name.outputs.version }}

.github/workflows/build-linux.yaml

Lines changed: 138 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,138 @@
1+
name: Build Static Linux Binaries
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
ref_name:
7+
description: "the ref (tag/branch) to use to extract tag/version"
8+
required: true
9+
type: string
10+
workflow_call:
11+
inputs:
12+
ref_name:
13+
description: "the ref (tag/branch) to use to extract tag/version"
14+
required: true
15+
type: string
16+
version:
17+
description: "override for version, will be used instead of ref if set, used for testing"
18+
required: false
19+
type: string
20+
schedule:
21+
- cron: '0 9 * * *'
22+
23+
permissions:
24+
# This is required for configure-aws-credentials to request an OIDC JWT ID token to access AWS resources later on.
25+
# More info: https://docs.github.com/en/actions/deployment/security-hardening-your-deployments/about-security-hardening-with-openid-connect#adding-permissions-settings
26+
id-token: write
27+
contents: read # this is required for actions/checkout
28+
29+
jobs:
30+
get-tag-name:
31+
name: Get tag name
32+
uses: ./.github/workflows/get-version-and-tag-for-ref.yaml
33+
with:
34+
ref_name: ${{ inputs.ref_name }}
35+
version: ${{ inputs.version }}
36+
37+
generate-artifacts:
38+
needs: get-tag-name
39+
runs-on: ubuntu-latest
40+
env:
41+
# Set during setup.
42+
RELEASE_VERSION: ${{ needs.get-tag-name.outputs.version }}
43+
steps:
44+
- uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
45+
with:
46+
ref: ${{ inputs.tag }}
47+
fetch-depth: 0
48+
persist-credentials: false
49+
submodules: recursive
50+
- uses: actions/setup-go@4dc6199c7b1a012772edbd06daecab0f50c9053c # v6.1.0
51+
with:
52+
go-version-file: go.mod
53+
cache: true
54+
- name: "Echo RELEASE_VERSION ENV"
55+
run: echo ${{ env.RELEASE_VERSION }}
56+
- name: Build
57+
id: build
58+
run: |
59+
RELEASE_VERSION="${{ env.RELEASE_VERSION }}"
60+
sudo make check-licenses download-licenses
61+
62+
# static amd64
63+
export STATIC_AMD64_BINARY_NAME="finch-${RELEASE_VERSION}-linux-amd64-static.tar.gz"
64+
sudo GOARCH=amd64 STATIC=1 make
65+
pushd _output/
66+
sudo touch "${STATIC_AMD64_BINARY_NAME}"
67+
sudo tar --exclude "*.tar.gz" --exclude "*.tar.gz.sha256sum" -cvzf "${STATIC_AMD64_BINARY_NAME}" .
68+
echo "STATIC_AMD64_BINARY_NAME=${STATIC_AMD64_BINARY_NAME}" >> ${GITHUB_OUTPUT}
69+
popd
70+
sudo rm -rf ./_output/bin/
71+
72+
# static arm64
73+
export STATIC_ARM64_BINARY_NAME="finch-${RELEASE_VERSION}-linux-arm64-static.tar.gz"
74+
sudo GOARCH=arm64 STATIC=1 make
75+
pushd _output/
76+
sudo touch "${STATIC_ARM64_BINARY_NAME}"
77+
sudo tar --exclude "*.tar.gz" --exclude "*.tar.gz.sha256sum" -cvzf "${STATIC_ARM64_BINARY_NAME}" .
78+
echo "STATIC_ARM64_BINARY_NAME=${STATIC_ARM64_BINARY_NAME}" >> ${GITHUB_OUTPUT}
79+
popd
80+
sudo rm -rf ./_output/bin/
81+
82+
pushd _output/
83+
sudo sh -c "sha256sum '${STATIC_AMD64_BINARY_NAME}' > '${STATIC_AMD64_BINARY_NAME}.sha256sum'"
84+
sudo sh -c "sha256sum '${STATIC_ARM64_BINARY_NAME}' > '${STATIC_ARM64_BINARY_NAME}.sha256sum'"
85+
popd
86+
- name: Verify release versions
87+
run: |
88+
ARCH=$(uname -m)
89+
if [ "$ARCH" = "x86_64" ]; then
90+
GOARCH="amd64"
91+
BINARY_NAME="${{ steps.build.outputs.STATIC_AMD64_BINARY_NAME }}"
92+
elif [ "$ARCH" = "aarch64" ]; then
93+
GOARCH="arm64"
94+
BINARY_NAME="${{ steps.build.outputs.STATIC_ARM64_BINARY_NAME }}"
95+
else
96+
echo "Unsupported architecture: $ARCH"
97+
exit 1
98+
fi
99+
100+
sudo mkdir -p ./_output/${{ env.RELEASE_VERSION }}/static/$GOARCH
101+
sudo tar -xzf ./_output/$BINARY_NAME -C ./_output/${{ env.RELEASE_VERSION }}/static/$GOARCH
102+
finch_version=$(sudo ./_output/${{ env.RELEASE_VERSION }}/static/$GOARCH/bin/finch --version)
103+
BINARY_VERSION=$(echo $finch_version | sed -n 's/finch version //p')
104+
export RELEASE_VERSION=${{ env.RELEASE_VERSION }}
105+
if [ "$BINARY_VERSION" != "$RELEASE_VERSION" ]; then
106+
echo "Version mismatch for $GOARCH binary"
107+
echo "RELEASE_VERSION = ${RELEASE_VERSION}"
108+
echo "finch_version = ${finch_version}"
109+
exit 1
110+
fi
111+
- uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6.0.0
112+
with:
113+
name: artifacts
114+
path: |
115+
_output/${{ steps.build.outputs.STATIC_AMD64_BINARY_NAME }}
116+
_output/${{ steps.build.outputs.STATIC_AMD64_BINARY_NAME }}.sha256sum
117+
_output/${{ steps.build.outputs.STATIC_ARM64_BINARY_NAME }}
118+
_output/${{ steps.build.outputs.STATIC_ARM64_BINARY_NAME }}.sha256sum
119+
if-no-files-found: error
120+
outputs:
121+
static_amd64_binary_name: ${{ steps.build.outputs.STATIC_AMD64_BINARY_NAME }}
122+
static_arm64_binary_name: ${{ steps.build.outputs.STATIC_ARM64_BINARY_NAME }}
123+
124+
# TODO: do we need to sign them or upload them to GitHub releases?
125+
upload-artifacts:
126+
needs:
127+
- generate-artifacts
128+
runs-on: ubuntu-latest
129+
steps:
130+
- uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8
131+
with:
132+
name: artifacts
133+
- name: upload to S3
134+
run: |
135+
aws s3 cp --no-progress ${{ needs.generate-artifacts.outputs.static_amd64_binary_name }} s3://${{ secrets.INSTALLER_PRIVATE_BUCKET_NAME }}/
136+
aws s3 cp --no-progress ${{ needs.generate-artifacts.outputs.static_amd64_binary_name }}.sha256sum s3://${{ secrets.INSTALLER_PRIVATE_BUCKET_NAME }}/
137+
aws s3 cp --no-progress ${{ needs.generate-artifacts.outputs.static_arm64_binary_name }} s3://${{ secrets.INSTALLER_PRIVATE_BUCKET_NAME }}/
138+
aws s3 cp --no-progress ${{ needs.generate-artifacts.outputs.static_arm64_binary_name }}.sha256sum s3://${{ secrets.INSTALLER_PRIVATE_BUCKET_NAME }}/

0 commit comments

Comments
 (0)