Skip to content

Commit

Permalink
Update build script
Browse files Browse the repository at this point in the history
  • Loading branch information
austinv900 committed Sep 3, 2023
1 parent 3646978 commit 68466a4
Show file tree
Hide file tree
Showing 2 changed files with 68 additions and 26 deletions.
59 changes: 33 additions & 26 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,51 +1,58 @@
---
name: Build

on: [ push, pull_request, workflow_dispatch ]

on:
workflow-call:
inputs:
branch-postfix:
required: false
type: string
env:
BUILD: ${{ inputs.branch-postfix == 'master' && 'Release' || 'Debug' }}
jobs:
build:
runs-on: windows-latest

steps:
- uses: actions/checkout@v3
with:
submodules: true

- uses: actions/setup-dotnet@v3
with:
dotnet-version: '7.0.x'

dotnet-version: 7.0.x
- name: Build Executables
shell: pwsh
run: |
dotnet publish --nologo -c Release -r win-x64
dotnet publish --nologo -c Release -r win-x86
dotnet publish --nologo -c Release -r osx-x64
dotnet publish --nologo -c Release -r linux-x64
run: >
dotnet publish --nologo -c $env:BUILD -r win-x64
dotnet publish --nologo -c $env:BUILD -r win-x86
dotnet publish --nologo -c $env:BUILD -r osx-x64
dotnet publish --nologo -c $env:BUILD -r linux-x64
$artifactPath = Join-Path (Get-Location) 'artifacts'
if (!(Test-Path $artifactPath))
{
New-Item $artifactPath -ItemType Directory -Force
}
$startPath = Join-Path (Get-Location) 'src' 'bin' 'Release' 'net7.0'
$startPath = Join-Path (Get-Location) 'src' 'bin' $env:BUILD 'net7.0'
Copy-Item (Join-Path $startPath 'win-x64' 'publish' 'Oxide.Compiler.exe') (Join-Path $artifactPath 'win-x64.Compiler.exe') -Force
Copy-Item (Join-Path $startPath 'win-x86' 'publish' 'Oxide.Compiler.exe') (Join-Path $artifactPath 'win-x86.Compiler.exe') -Force
Copy-Item (Join-Path $startPath 'linux-x64' 'publish' 'Oxide.Compiler') (Join-Path $artifactPath 'linux-x64.Compiler') -Force
Copy-Item (Join-Path $startPath 'osx-x64' 'publish' 'Oxide.Compiler') (Join-Path $artifactPath 'osx-x64.Compiler') -Force
Copy-Item (Join-Path $startPath 'osx-x64' 'publish' 'Oxide.Compiler') (Join-Path $artifactPath 'osx-x64.Compiler') -Force
- name: Generate MD5
run: >
Get-ChildItem -Path 'artifacts' | ForEach-Object { (Get-FileHash
$_.FullName -Algorithm MD5).Hash.ToLower() | Out-File -FilePath "$(
$_.FullName ).md5" }
- name: Publish Artifacts
uses: actions/upload-artifact@v3
if: ${{ success() }}
with:
name: bundle
name: oxide-compiler
path: artifacts/

- name: Deploy To cdn.oxidemod.cloud
if: github.event_name == 'push'
shell: pwsh
run: |
Install-Module -Name AWS.Tools.Installer -Force
Install-AWSToolsModule AWS.Tools.S3 -Force
Set-AWSCredential -AccessKey ${{ secrets.AWS_KEY }} -SecretKey ${{ secrets.AWS_SECRET }}
Write-S3Object -BucketName cdn.oxidemod.cloud -Folder (Join-Path (Get-Location) 'artifacts') -KeyPrefix compiler -Force -PublicReadOnly -Region us-west-2
Write-Output 'All files written to cloud cdn'
35 changes: 35 additions & 0 deletions .github/workflows/production.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
---
name: Deploy to Cloadflare R2
on:
push:
branches:
- master
- staging
- develop
- roslyn
jobs:
build:
name: Run Build
uses: ./.github/workflows/build.yml
secrets: inherit
with:
branch-postfix: ${{ github.ref_name }}
deploy:
name: Deploy to R2
runs-on: ubuntu-22.04
needs: build
steps:
- name: Download Artifacts
uses: actions/download-artifact@v3
with:
name: oxide-compiler
path: artifacts
- name: Deploy to Cloadflare R2
run: >
aws s3 sync artifacts s3://oxide-downloads/artifacts/compiler/${{
github.ref_name }} --endpoint-url ${{ secrets.CLOUDFLARE_R2_ENDPOINT
}} --acl public-read
env:
AWS_ACCESS_KEY_ID: ${{ secrets.CLOUDFLARE_R2_KEY }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.CLOUDFLARE_R2_SECRET }}
AWS_DEFAULT_REGION: auto

0 comments on commit 68466a4

Please sign in to comment.