Skip to content

Commit

Permalink
Merge pull request #52 from XanatosX/feature/41_add-live-build-pipeline
Browse files Browse the repository at this point in the history
Add build pipeline for releases
  • Loading branch information
XanatosX authored Feb 1, 2023
2 parents 1c06a88 + 219f20f commit eeaca21
Show file tree
Hide file tree
Showing 3 changed files with 165 additions and 4 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/create-latest-develop-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,9 @@ jobs:
- name: Restore dependencies
run: dotnet restore
- name: Publish Application
run: dotnet publish ${{ env.APPLICATION_PROJECT_PATH }} -r win-x64 -c Release -o ${{ env.APPLICATION_PUBLISH_FOLDER }}
run: dotnet publish ${{ env.APPLICATION_PROJECT_PATH }} -r win-x64 -c Release -o ${{ env.APPLICATION_PUBLISH_FOLDER }} -p:Version=0.0.0
- 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
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=0.0.0
- name: Show content for debug
if: ${{ env.DEBUG == 'true' }}
run: ls
Expand Down Expand Up @@ -118,9 +118,9 @@ jobs:
- name: Restore dependencies
run: dotnet restore
- name: Publish Application
run: dotnet publish $APPLICATION_PROJECT_PATH -r linux-x64 -c Release -o $APPLICATION_PUBLISH_FOLDER
run: dotnet publish $APPLICATION_PROJECT_PATH -r linux-x64 -c Release -o $APPLICATION_PUBLISH_FOLDER -p:Version=0.0.0
- 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
run: dotnet publish $APPLICATION_PLUGIN_PROJECT_PATH -r linux-x64 -c Release -o $PLUGIN_PUBLISH_FOLDER /p:DebugType=None /p:DebugSymbols=false -p:Version=0.0.0
- name: Show content for debug
if: ${{ env.DEBUG == 'true' }}
run: ls -la
Expand Down
159 changes: 159 additions & 0 deletions .github/workflows/create-live-build.yml
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
2 changes: 2 additions & 0 deletions ModularToolManagerProject.sln
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ MinimumVisualStudioVersion = 10.0.40219.1
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{BE409F60-F5A2-4643-B028-F124F6CC151A}"
ProjectSection(SolutionItems) = preProject
.gitignore = .gitignore
.github\workflows\create-latest-develop-build.yml = .github\workflows\create-latest-develop-build.yml
.github\workflows\create-live-build.yml = .github\workflows\create-live-build.yml
README.md = README.md
EndProjectSection
EndProject
Expand Down

0 comments on commit eeaca21

Please sign in to comment.