Skip to content

Commit 0f870d5

Browse files
added workflow
1 parent a038115 commit 0f870d5

File tree

1 file changed

+119
-0
lines changed

1 file changed

+119
-0
lines changed

.github/workflows/build.yml

Lines changed: 119 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,119 @@
1+
name: Build Executable
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
name:
7+
description: 'Name of the build'
8+
required: true
9+
version:
10+
description: 'Version of the build'
11+
required: true
12+
commit:
13+
description: 'Commit SHA to build'
14+
required: true
15+
branch:
16+
description: 'Branch to checkout'
17+
required: true
18+
endpoint:
19+
description: 'Backend endpoint URL for uploading artifacts'
20+
required: true
21+
dispatchID:
22+
description: 'Dispatch ID'
23+
required: true
24+
token:
25+
description: 'Auth token'
26+
required: true
27+
28+
jobs:
29+
build:
30+
strategy:
31+
matrix:
32+
os: [macos-15-large]
33+
runs-on: ${{ matrix.os }}
34+
35+
steps:
36+
- uses: actions/checkout@v2
37+
with:
38+
ref: ${{ github.event.inputs.commit }}
39+
40+
- name: Set up Dart
41+
uses: dart-lang/[email protected]
42+
with:
43+
sdk: stable
44+
45+
# Windows-specific steps for setting up SSH and SSH-Agent
46+
- name: Setup custom SSH (Windows)
47+
if: runner.os == 'Windows'
48+
run: |
49+
echo "${{ secrets.GIT_SSH_KEY }}" | Out-File -Encoding ascii -FilePath ssh_key
50+
New-Item -ItemType Directory -Force -Path "$env:USERPROFILE\.ssh"
51+
Set-Content -Path "$env:USERPROFILE\.ssh\config" -Value @"
52+
Host gitlab.com-codewave
53+
HostName gitlab.com
54+
User git
55+
IdentityFile ${{ github.workspace }}\ssh_key
56+
StrictHostKeyChecking no
57+
"@
58+
ssh-keyscan -t rsa gitlab.com >> $env:USERPROFILE\.ssh\known_hosts
59+
Get-Content $env:USERPROFILE\.ssh\known_hosts
60+
chmod 600 ssh_key
61+
shell: powershell
62+
63+
- name: Setup custom SSH (Unix)
64+
if: runner.os != 'Windows'
65+
run: |
66+
echo "${{ secrets.GIT_SSH_KEY }}" > ssh_key
67+
chmod 600 ssh_key
68+
mkdir -p ~/.ssh
69+
echo "Host gitlab.com-codewave" >> ~/.ssh/config
70+
echo " HostName gitlab.com" >> ~/.ssh/config
71+
echo " User git" >> ~/.ssh/config
72+
echo " IdentityFile $(pwd)/ssh_key" >> ~/.ssh/config
73+
echo " StrictHostKeyChecking no" >> ~/.ssh/config
74+
ssh-keyscan -t rsa gitlab.com >> ~/.ssh/known_hosts
75+
chmod 600 ~/.ssh/config
76+
chmod 600 $(pwd)/ssh_key
77+
78+
- name: Setup SSH for GitLab Access
79+
uses: webfactory/[email protected]
80+
with:
81+
ssh-private-key: ${{ secrets.GIT_SSH_KEY }}
82+
83+
- name: Install dependencies
84+
run: dart pub get
85+
86+
- name: Compile to executable
87+
run: dart compile exe bin/${{ github.event.inputs.name }}.dart -o bin/${{ github.event.inputs.name }}_${{ github.event.inputs.version }}_${{ runner.os }}_executable
88+
89+
- name: Executable Permission
90+
run: chmod +x bin/${{ github.event.inputs.name }}_${{ github.event.inputs.version }}_${{ runner.os }}_executable
91+
if: runner.os != 'Windows' # Skip on Windows
92+
93+
- name: Upload Artifacts to Backend (Windows)
94+
if: runner.os == 'Windows'
95+
run: |
96+
& "C:\Program Files\Git\mingw64\bin\curl.exe" --location "http://3.6.230.135:8080/v1/process-artifacts" `
97+
--header "Authorization: ${{ github.event.inputs.token }}" `
98+
--form 'dispatch_id=${{ github.event.inputs.dispatchID }}' `
99+
--form 'operating_system=${{ runner.os }}' `
100+
--form 'artifact=@bin/${{ github.event.inputs.name }}_${{ github.event.inputs.version }}_${{ runner.os }}_executable'
101+
shell: powershell
102+
103+
- name: Upload Artifacts to Backend (Unix)
104+
if: runner.os != 'Windows'
105+
run: |
106+
curl --location "http://3.6.230.135:8080/v1/process-artifacts" \
107+
--header "Authorization: ${{ github.event.inputs.token }}" \
108+
--form 'dispatch_id=${{ github.event.inputs.dispatchID }}' \
109+
--form 'operating_system=${{ runner.os }}' \
110+
--form 'artifact=@bin/${{ github.event.inputs.name }}_${{ github.event.inputs.version }}_${{ runner.os }}_executable'
111+
112+
- name: Cleanup Artifacts (Windows)
113+
if: runner.os == 'Windows'
114+
run: Remove-Item -Path "bin/${{ github.event.inputs.name }}_${{ github.event.inputs.version }}_${{ runner.os }}_executable" -Force
115+
shell: powershell
116+
117+
- name: Cleanup Artifacts (Unix)
118+
if: runner.os != 'Windows'
119+
run: rm -f bin/${{ github.event.inputs.name }}_${{ github.event.inputs.version }}_${{ runner.os }}_executable

0 commit comments

Comments
 (0)