-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #52 from XanatosX/feature/41_add-live-build-pipeline
Add build pipeline for releases
- Loading branch information
Showing
3 changed files
with
165 additions
and
4 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,159 @@ | ||
name: Live build | ||
|
||
# Based on https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#release | ||
on: | ||
release: | ||
types: [released] | ||
|
||
env: | ||
DEBUG: false | ||
REF_CHECKOUT_BRANCH: main | ||
#RELEASE_NAME: Recent nightly build | ||
APPLICATION_PROJECT_PATH: .\src\ModularToolManager\ModularToolManager.csproj | ||
APPLICATION_PLUGIN_PROJECT_PATH: .\src\DefaultPlugins\DefaultPlugins.csproj | ||
APPLICATION_PUBLISH_FOLDER: ./publish | ||
PLUGIN_PUBLISH_FOLDER: ./publish/plugins | ||
WINDOWS_ARTIFACT_NAME: WindowsBuildArtifact_x64 | ||
LINUX_ARTIFACT_NAME: LinuxBuildArtifact_x64 | ||
RELEASE_ARTIFACT_FOLDER: artifacts | ||
|
||
jobs: | ||
check-build: | ||
name: Check and Test build | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
with: | ||
ref: ${{ env.REF_CHECKOUT_BRANCH }} | ||
lfs: true | ||
- name: Setup .NET | ||
uses: actions/setup-dotnet@v2 | ||
with: | ||
dotnet-version: 7.0.x | ||
- name: Restore dependencies | ||
run: dotnet restore | ||
- name: Build | ||
run: dotnet build --no-restore | ||
- name: Test | ||
run: dotnet test --no-build --verbosity normal | ||
build-version: | ||
name: Get version for build | ||
runs-on: ubuntu-22.04 | ||
outputs: | ||
build-version: ${{ steps.build-version.outputs.build-version }} | ||
steps: | ||
- name: Get release version | ||
id: build-version | ||
run: | | ||
# Found at https://github.com/orgs/community/discussions/25713 | ||
# Additional env fix found on https://github.com/actions/runner-images/issues/5251 | ||
if [ '${{ GITHUB.REF_TYPE }}' == 'branch' ] | ||
then | ||
echo "Running on branch (Check successful)" | ||
echo "build-version=${{ GITHUB.REF_NAME }}" >> $GITHUB_OUTPUT | ||
else | ||
echo "Is not running on branch (Check failed)" | ||
echo "build-version=0.0.0" >> $GITHUB_OUTPUT | ||
fi | ||
create-windows-build: | ||
name: Create Windows build | ||
needs: ["check-build", "build-version"] | ||
runs-on: windows-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
with: | ||
ref: ${{ env.REF_CHECKOUT_BRANCH }} | ||
lfs: true | ||
- name: Setup .NET | ||
uses: actions/setup-dotnet@v2 | ||
with: | ||
dotnet-version: 6.0.x | ||
- name: Restore dependencies | ||
run: dotnet restore | ||
# Important for using outputs in other steps https://tech.europace.de/post/github-actions-output-variables-how-to/#get-output-values-between-steps | ||
- name: Publish Application | ||
run: dotnet publish ${{ env.APPLICATION_PROJECT_PATH }} -r win-x64 -c Release -o ${{ env.APPLICATION_PUBLISH_FOLDER }} -p:Version=${{ needs.build-version.outputs.build-version }} | ||
- name: Publish Plugin | ||
run: dotnet publish ${{ env.APPLICATION_PLUGIN_PROJECT_PATH }} -r win-x64 -c Release -o ${{ env.PLUGIN_PUBLISH_FOLDER }} /p:DebugType=None /p:DebugSymbols=false -p:Version=${{ needs.build-version.outputs.build-version }} | ||
- name: Show content for debug | ||
if: ${{ env.DEBUG == 'true' }} | ||
run: ls | ||
- name: Show content to publish | ||
if: ${{ env.DEBUG == 'true' }} | ||
run: | | ||
cd ./publish | ||
ls | ||
- name: Upload artifacts | ||
uses: actions/upload-artifact@v2 | ||
with: | ||
name: ${{ env.WINDOWS_ARTIFACT_NAME }} | ||
path: ${{ env.APPLICATION_PUBLISH_FOLDER }} | ||
if-no-files-found: error | ||
create-linux-build: | ||
name: Create Linux build | ||
needs: ["check-build", "build-version"] | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
with: | ||
ref: ${{ env.REF_CHECKOUT_BRANCH }} | ||
lfs: true | ||
- name: Setup .NET | ||
uses: actions/setup-dotnet@v2 | ||
with: | ||
dotnet-version: 6.0.x | ||
- name: Restore dependencies | ||
run: dotnet restore | ||
- name: Publish Application | ||
run: dotnet publish $APPLICATION_PROJECT_PATH -r linux-x64 -c Release -o $APPLICATION_PUBLISH_FOLDER -p:Version=${{ needs.build-version.outputs.build-version }} | ||
- name: Publish Plugin | ||
run: dotnet publish $APPLICATION_PLUGIN_PROJECT_PATH -r linux-x64 -c Release -o $PLUGIN_PUBLISH_FOLDER /p:DebugType=None /p:DebugSymbols=false -p:Version=${{ needs.build-version.outputs.build-version }} | ||
- name: Show content for debug | ||
if: ${{ env.DEBUG == 'true' }} | ||
run: ls -la | ||
- name: Show content to publish | ||
if: ${{ env.DEBUG == 'true' }} | ||
run: | | ||
cd ./publish | ||
ls -la | ||
- name: Upload artifacts | ||
uses: actions/upload-artifact@v2 | ||
with: | ||
name: ${{ env.LINUX_ARTIFACT_NAME }} | ||
path: ${{ env.APPLICATION_PUBLISH_FOLDER }} | ||
if-no-files-found: error | ||
upload-release: | ||
name: Upload Artifacts to release | ||
needs: ["create-windows-build", "create-linux-build"] | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
with: | ||
ref: ${{ env.REF_CHECKOUT_BRANCH }} | ||
lfs: true | ||
- name: Download artifacts | ||
uses: actions/download-artifact@v3 | ||
with: | ||
path: ${{ env.RELEASE_ARTIFACT_FOLDER }} | ||
- name: Zip Windows build | ||
run: | | ||
cd ./$RELEASE_ARTIFACT_FOLDER/$WINDOWS_ARTIFACT_NAME | ||
zip -r $WINDOWS_ARTIFACT_NAME.zip ./* | ||
mv $WINDOWS_ARTIFACT_NAME.zip ../ | ||
rm -rf ./../$WINDOWS_ARTIFACT_NAME | ||
- name: Zip Linux build | ||
run: | | ||
cd ./$RELEASE_ARTIFACT_FOLDER/$LINUX_ARTIFACT_NAME | ||
zip -r $LINUX_ARTIFACT_NAME.zip ./* | ||
mv $LINUX_ARTIFACT_NAME.zip ../ | ||
rm -rf ./../$LINUX_ARTIFACT_NAME | ||
- name: Display artifacts folder content | ||
if: ${{ env.DEBUG == 'true' }} | ||
run: ls -la $RELEASE_ARTIFACT_FOLDER | ||
- name: Upload artifacts | ||
if: ${{ env.DEBUG == 'false' }} | ||
env: | ||
GH_TOKEN: ${{ github.token }} | ||
run: | | ||
gh release upload ${{ GITHUB.REF_NAME }} ${{ env.RELEASE_ARTIFACT_FOLDER }}/*.zip | ||
#gh release upload ${{ GITHUB.REF_NAME }} ${{ env.RELEASE_ARTIFACT_FOLDER }}/*.nupkg |
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