Skip to content

Commit

Permalink
add github action
Browse files Browse the repository at this point in the history
  • Loading branch information
robinroyer committed May 29, 2024
1 parent 8d61fba commit 5e51a52
Showing 1 changed file with 100 additions and 0 deletions.
100 changes: 100 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@

name: Qarnot CLI release

on:
# tags:
# - 'v*.*.*'
push:
branches: [ "master", "*" ]
pull_request:
branches: [ "master", "*" ]
workflow_dispatch:


jobs:
build-and-release:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, windows-latest]

steps:
- uses: actions/checkout@v4
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: 6.0.x
- name: Env Info
run: dotnet --info
- name: Build
run: dotnet build -c Release
- name: Test
run: dotnet test --no-build --verbosity normal -c Release

# OSX
- name: Release OSX x64
if: runner.os != 'Windows'
run: dotnet publish QarnotCLI/QarnotCLI.csproj -c Release -r osx-x64 --self-contained true /p:PublishSingleFile=true -o ./artifacts/osx
- name: Move OSX artifacts
if: runner.os != 'Windows'
run: mv ./artifacts/osx/qarnot ./artifacts/qarnot-osx-x64

# Linux
- name: Release Linux x64
if: runner.os != 'Windows'
run: dotnet publish QarnotCLI/QarnotCLI.csproj -c Release -r linux-x64 --self-contained true /p:PublishSingleFile=true -o ./artifacts/linux
- name: Move Linux artifacts
if: runner.os != 'Windows'
run: mv ./artifacts/linux/qarnot ./artifacts/qarnot-linux-x64

# Win
- name: Release win x64
if: runner.os != 'Windows'
run: dotnet publish QarnotCLI/QarnotCLI.csproj -c Release -r win-x64 --self-contained true /p:PublishSingleFile=true -o ./artifacts/windows
- name: Move win artifacts
if: runner.os != 'Windows'
run: mv ./artifacts/windows/qarnot.exe ./artifacts/qarnot-windows-x64.exe

- name: Clean artifacts
if: runner.os != 'Windows'
# only keep one version of this, otherwise it'll fail to upload to Github (duplicate)
run: |
rm -f artifacts/*/*.pdb
rm -f artifacts/windows/qarnot.xml
rm -f artifacts/osx/qarnot.xml
- name: Compress Artifacts
if: runner.os != 'Windows'
run: zip -r binaries-zip ./artifacts

- name: Create GitHub Release
if: runner.os != 'Windows'
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.ref }}
release_name: Release ${{ github.ref }}
draft: true
prerelease: true # TODO: change me when ready to merge

- name: Upload Artifacts zip
if: runner.os != 'Windows'
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: binaries-zip
asset_name: binaries-zip
asset_content_type: application/zip

- name: Upload Artifacts
if: runner.os != 'Windows'
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./artifacts/**/*

0 comments on commit 5e51a52

Please sign in to comment.