Build Executable #35
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
name: Build Executable | |
on: | |
workflow_dispatch: | |
inputs: | |
name: | |
description: "Name of the build" | |
required: true | |
version: | |
description: "Version of the build" | |
required: true | |
commit: | |
description: "Commit SHA to build" | |
required: true | |
branch: | |
description: "Branch to checkout" | |
required: true | |
endpoint: | |
description: "Backend endpoint URL for uploading artifacts" | |
required: true | |
dispatchID: | |
description: "Dispatch ID" | |
required: true | |
token: | |
description: "Auth token" | |
required: true | |
jobs: | |
build: | |
strategy: | |
matrix: | |
os: [macos-latest, ubuntu-latest, windows-latest] | |
runs-on: ${{ matrix.os }} | |
steps: | |
- uses: actions/checkout@v2 | |
with: | |
ref: ${{ github.event.inputs.commit }} | |
- name: Set up Dart | |
uses: dart-lang/setup-dart@v1.3 | |
with: | |
sdk: stable | |
# Windows-specific steps for setting up SSH and SSH-Agent | |
- name: Setup custom SSH (Windows) | |
if: runner.os == 'Windows' | |
run: | | |
echo "${{ secrets.GIT_SSH_KEY }}" | Out-File -Encoding ascii -FilePath ssh_key | |
New-Item -ItemType Directory -Force -Path "$env:USERPROFILE\.ssh" | |
Set-Content -Path "$env:USERPROFILE\.ssh\config" -Value @" | |
Host gitlab.com-codewave | |
HostName gitlab.com | |
User git | |
IdentityFile ${{ github.workspace }}\ssh_key | |
StrictHostKeyChecking no | |
"@ | |
ssh-keyscan -t rsa gitlab.com >> $env:USERPROFILE\.ssh\known_hosts | |
Get-Content $env:USERPROFILE\.ssh\known_hosts | |
chmod 600 ssh_key | |
shell: powershell | |
- name: Setup custom SSH (Unix) | |
if: runner.os != 'Windows' | |
run: | | |
echo "${{ secrets.GIT_SSH_KEY }}" > ssh_key | |
chmod 600 ssh_key | |
mkdir -p ~/.ssh | |
echo "Host gitlab.com-codewave" >> ~/.ssh/config | |
echo " HostName gitlab.com" >> ~/.ssh/config | |
echo " User git" >> ~/.ssh/config | |
echo " IdentityFile $(pwd)/ssh_key" >> ~/.ssh/config | |
echo " StrictHostKeyChecking no" >> ~/.ssh/config | |
ssh-keyscan -t rsa gitlab.com >> ~/.ssh/known_hosts | |
chmod 600 ~/.ssh/config | |
chmod 600 $(pwd)/ssh_key | |
- name: Setup SSH for GitLab Access | |
uses: webfactory/ssh-agent@v0.5.3 | |
with: | |
ssh-private-key: ${{ secrets.GIT_SSH_KEY }} | |
- name: Install dependencies | |
run: dart pub get | |
- name: Compile to executable | |
run: dart compile exe bin/${{ github.event.inputs.name }}.dart -o bin/${{ github.event.inputs.name }}_${{ github.event.inputs.version }}_${{ runner.os }}_executable | |
- name: Executable Permission | |
run: chmod +x bin/${{ github.event.inputs.name }}_${{ github.event.inputs.version }}_${{ runner.os }}_executable | |
if: runner.os != 'Windows' # Skip on Windows | |
- name: Upload Artifacts to Backend (Windows) | |
if: runner.os == 'Windows' | |
run: | | |
& "C:\Program Files\Git\mingw64\bin\curl.exe" --location "http://3.6.230.135:8080/v1/process-artifacts" ` | |
--header "Authorization: ${{ github.event.inputs.token }}" ` | |
--form 'dispatch_id=${{ github.event.inputs.dispatchID }}' ` | |
--form 'operating_system=${{ runner.os }}' ` | |
--form 'artifact=@bin/${{ github.event.inputs.name }}_${{ github.event.inputs.version }}_${{ runner.os }}_executable' | |
shell: powershell | |
- name: Upload Artifacts to Backend (Unix) | |
if: runner.os != 'Windows' | |
run: | | |
curl --location "http://3.6.230.135:8080/v1/process-artifacts" \ | |
--header "Authorization: ${{ github.event.inputs.token }}" \ | |
--form 'dispatch_id=${{ github.event.inputs.dispatchID }}' \ | |
--form 'operating_system=${{ runner.os }}' \ | |
--form 'artifact=@bin/${{ github.event.inputs.name }}_${{ github.event.inputs.version }}_${{ runner.os }}_executable' | |
- name: Cleanup Artifacts (Windows) | |
if: runner.os == 'Windows' | |
run: Remove-Item -Path "bin/${{ github.event.inputs.name }}_${{ github.event.inputs.version }}_${{ runner.os }}_executable" -Force | |
shell: powershell | |
- name: Cleanup Artifacts (Unix) | |
if: runner.os != 'Windows' | |
run: rm -f bin/${{ github.event.inputs.name }}_${{ github.event.inputs.version }}_${{ runner.os }}_executable |