Merge branch 'feature/github-actions'
This commit is contained in:
75
.github/workflows/github-actions.yml
vendored
Normal file
75
.github/workflows/github-actions.yml
vendored
Normal file
@@ -0,0 +1,75 @@
|
|||||||
|
name: Alma build
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
tags:
|
||||||
|
- "v*"
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build:
|
||||||
|
runs-on: ${{ matrix.target.runner }}
|
||||||
|
strategy:
|
||||||
|
matrix:
|
||||||
|
target:
|
||||||
|
- runtime: win-x64
|
||||||
|
runner: windows-latest
|
||||||
|
name: windows
|
||||||
|
outputname: Alma.exe
|
||||||
|
version_script: .scripts/versioning.ps1
|
||||||
|
- runtime: linux-x64
|
||||||
|
runner: ubuntu-latest
|
||||||
|
name: linux
|
||||||
|
outputname: Alma
|
||||||
|
version_script: .scripts/versioning.sh
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
- name: Setup dotnet
|
||||||
|
uses: actions/setup-dotnet@v3
|
||||||
|
with:
|
||||||
|
dotnet-version: '7.0.x'
|
||||||
|
- name: Patch version
|
||||||
|
run: ${{ matrix.target.version_script }}
|
||||||
|
continue-on-error: true
|
||||||
|
- name: Restore dependencies
|
||||||
|
run: dotnet restore src/Alma
|
||||||
|
- name: Build
|
||||||
|
run: dotnet publish -c Release -p:PublishAot=true -r ${{ matrix.target.runtime }} -o app/ src/Alma
|
||||||
|
- uses: actions/upload-artifact@v3
|
||||||
|
with:
|
||||||
|
name: alma-${{ matrix.target.name }}
|
||||||
|
path: app/${{ matrix.target.outputname }}
|
||||||
|
|
||||||
|
release:
|
||||||
|
needs: build
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/download-artifact@v3
|
||||||
|
name: Download Windows artifacts
|
||||||
|
with:
|
||||||
|
name: alma-windows
|
||||||
|
path: app/windows/
|
||||||
|
- uses: actions/download-artifact@v3
|
||||||
|
name: Download Linux artifacts
|
||||||
|
with:
|
||||||
|
name: alma-linux
|
||||||
|
path: app/linux/
|
||||||
|
|
||||||
|
- name: Create release directory
|
||||||
|
run: mkdir release
|
||||||
|
|
||||||
|
- name: Copy windows executable
|
||||||
|
run: cp app/windows/Alma.exe release/alma.exe
|
||||||
|
|
||||||
|
- name: Copy linux executable
|
||||||
|
run: cp app/linux/Alma release/alma-linux
|
||||||
|
|
||||||
|
- uses: "marvinpinto/action-automatic-releases@latest"
|
||||||
|
name: Create release
|
||||||
|
with:
|
||||||
|
title: Test
|
||||||
|
repo_token: "${{ secrets.GITHUB_TOKEN }}"
|
||||||
|
automatic_release_tag: latest
|
||||||
|
prerelease: false
|
||||||
|
draft: true
|
||||||
|
files: |
|
||||||
|
release/alma*
|
||||||
15
.scripts/versioning.ps1
Normal file
15
.scripts/versioning.ps1
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
gci env:\
|
||||||
|
|
||||||
|
if((Get-Content env:\GITHUB_REF_TYPE) -ne "tag")
|
||||||
|
{
|
||||||
|
Return
|
||||||
|
}
|
||||||
|
|
||||||
|
$version = (Get-Content env:\GITHUB_REF).Replace("refs/tags/v", "")
|
||||||
|
$git_sha = (Get-Content env:\GITHUB_SHA).Substring(0, 8)
|
||||||
|
|
||||||
|
Write-Host $version
|
||||||
|
Write-Host $git_sha
|
||||||
|
|
||||||
|
(Get-Content src\Alma\Alma.csproj).Replace("0.0.0", $version).Replace("development", $git_sha) | Set-Content src\Alma\Alma.csproj
|
||||||
|
Write-Host (Get-Content src\Alma\Alma.csproj)
|
||||||
16
.scripts/versioning.sh
Executable file
16
.scripts/versioning.sh
Executable file
@@ -0,0 +1,16 @@
|
|||||||
|
printenv
|
||||||
|
|
||||||
|
if [ ${GITHUB_REF_TYPE} != "tag" ]; then
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
version="${GITHUB_REF:11}"
|
||||||
|
git_hash="${GITHUB_SHA}"
|
||||||
|
echo $git_hash
|
||||||
|
git_hash=`expr substr $git_hash 1 8`
|
||||||
|
|
||||||
|
echo $version
|
||||||
|
echo $git_hash
|
||||||
|
|
||||||
|
sed -i "s/0.0.0/$version/g;s/development/$git_hash/g" src/Alma/Alma.csproj
|
||||||
|
cat src/Alma/Alma.csproj
|
||||||
@@ -14,6 +14,8 @@
|
|||||||
<TargetFramework>net7.0</TargetFramework>
|
<TargetFramework>net7.0</TargetFramework>
|
||||||
<ImplicitUsings>enable</ImplicitUsings>
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
|
<VersionPrefix>0.0.0</VersionPrefix>
|
||||||
|
<VersionSuffix>development</VersionSuffix>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
|||||||
Reference in New Issue
Block a user