Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add nuget deployment #22

Merged
merged 19 commits into from
Jan 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
72 changes: 71 additions & 1 deletion .github/workflows/create-live-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ env:
RELEASE_NAME: Recent nightly build
APPLICATION_PUBLISH_FOLDER: ./publish
WINDOWS_ARTIFACT_NAME: IL_2_Career_Toolset_windows_x64
WINDOWS_NUGET_ARTIFACT_NAME: IL_2_Career_Toolset_Nuget_windows_x64
RELEASE_ARTIFACT_FOLDER: artifacts
GH_TOKEN: ${{ github.token }}

Expand Down Expand Up @@ -76,9 +77,50 @@ jobs:
name: ${{ env.WINDOWS_ARTIFACT_NAME }}
path: ${{ env.APPLICATION_PUBLISH_FOLDER }}
if-no-files-found: error
create-windows-nuget-tool-build:
name: Build nuget tool
needs: ["check-build"]
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: 7.0.x
- name: Restore dependencies
run: dotnet restore
- name: Get release 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 }}' -eq 'branch' ) {
echo "BUILD_VERSION=0.0.0" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
}
else {
echo "BUILD_VERSION=${{ GITHUB.REF_NAME }}" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
}
- name: Pack application
run: dotnet pack -o ${{ env.APPLICATION_PUBLISH_FOLDER }} -p:Version=${{ env.BUILD_VERSION }}
- name: Show content for debug
if: ${{ env.DEBUG == 'true' }}
run: ls
- name: Show content which was packed
if: ${{ env.DEBUG == 'true' }}
run: |
cd ./publish
ls
- name: Upload artifacts
uses: actions/upload-artifact@v2
with:
name: ${{ env.WINDOWS_NUGET_ARTIFACT_NAME }}
path: ${{ env.APPLICATION_PUBLISH_FOLDER }}
if-no-files-found: error
upload-release:
name: Upload Artifacts to release
needs: ["create-windows-build"]
needs: ["create-windows-build", "create-windows-nuget-tool-build"]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
Expand All @@ -94,10 +136,38 @@ jobs:
cd ./$RELEASE_ARTIFACT_FOLDER/$WINDOWS_ARTIFACT_NAME
zip -r $WINDOWS_ARTIFACT_NAME.zip ./*
mv $WINDOWS_ARTIFACT_NAME.zip ../
rm -rf ./../$WINDOWS_ARTIFACT_NAME
- name: Move nuget tool
run: |
mv ./$RELEASE_ARTIFACT_FOLDER/$WINDOWS_NUGET_ARTIFACT_NAME/IL2CareerToolset*.nupkg ./$RELEASE_ARTIFACT_FOLDER
rm -rf ./$RELEASE_ARTIFACT_FOLDER/$WINDOWS_NUGET_ARTIFACT_NAME/
- name: Display artifacts folder content
if: ${{ env.DEBUG == 'true' }}
run: ls -la $RELEASE_ARTIFACT_FOLDER
- name: Upload artifacts
if: ${{ env.DEBUG == 'false' }}
run: |
gh release upload ${{ GITHUB.REF_NAME }} ${{ env.RELEASE_ARTIFACT_FOLDER }}/*.zip
gh release upload ${{ GITHUB.REF_NAME }} ${{ env.RELEASE_ARTIFACT_FOLDER }}/*.nupkg
upload-nuget-releases:
name: Upload Nuget packages
#if: github.event_name == 'release'
needs: [upload-release]
runs-on: ubuntu-latest
steps:
- uses: actions/download-artifact@v3
with:
name: ${{ env.WINDOWS_NUGET_ARTIFACT_NAME }}
path: ${{ env.RELEASE_ARTIFACT_FOLDER }}
- name: Setup .NET Core
uses: actions/setup-dotnet@v3
- name: Show content for publishing
if: ${{ env.DEBUG == 'true' }}
run: ls -la ${{ env.RELEASE_ARTIFACT_FOLDER }}
- name: Publish NuGet package
if: ${{ env.DEBUG == 'false' }}
env: # See https://www.techielass.com/github-actions-secrets/
nuget_apikey: ${{ secrets.NUGET_API_KEY }}
run: |
cd ${{ env.RELEASE_ARTIFACT_FOLDER }}
dotnet nuget push *.nupkg --api-key "${{ env.nuget_apikey }}" --source https://api.nuget.org/v3/index.json
29 changes: 8 additions & 21 deletions .github/workflows/create-nightly-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,9 @@ on:
workflow_dispatch:
schedule:
- cron: 0 0 * * *
push:

env:
DEBUG: true
DEBUG: false
REF_CHECKOUT_BRANCH: develop
RELEASE_NAME: Recent nightly build
APPLICATION_PUBLISH_FOLDER: ./publish
Expand All @@ -24,9 +23,6 @@ jobs:
should-run: ${{ steps.should-run.outputs.should-run }}
steps:
- uses: actions/checkout@v3
if: ${{ env.DEBUG == 'true' }}
- uses: actions/checkout@v3
if: ${{ env.DEBUG == 'false' }}
with:
ref: ${{ env.REF_CHECKOUT_BRANCH }}
- name: get latest commit and check it
Expand All @@ -37,6 +33,7 @@ jobs:
# @Note: Check the comments on the solution!
run: |
latest=$(git log -n 1 --pretty=format:"%H")
# For debug testing remove ${{ env.REF_CHECKOUT_BRANCH }}
sha=$(git rev-list ${{ env.REF_CHECKOUT_BRANCH }} --after="24 hours" $latest)
echo $sha
echo Do the check now
Expand All @@ -51,7 +48,7 @@ jobs:
check-build:
name: Check and Test build
# Based on https://stackoverflow.com/questions/59882715/use-environment-variable-in-github-action-if
if: needs.check-for-changes.outputs.should-run == 'true'
if: needs.check-for-changes.outputs.should-run == 'true'
needs: [check-for-changes]
runs-on: ubuntu-latest
steps:
Expand Down Expand Up @@ -118,18 +115,8 @@ jobs:
dotnet-version: 7.0.x
- name: Restore dependencies
run: dotnet restore
- name: Get release 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 }}' -eq 'branch' ) {
echo "BUILD_VERSION=0.0.0" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
}
else {
echo "BUILD_VERSION=${{ GITHUB.REF_NAME }}" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
}
- name: Pack application
run: dotnet pack -o ${{ env.APPLICATION_PUBLISH_FOLDER }} -p:Version=${{ env.BUILD_VERSION }}
run: dotnet pack -o ${{ env.APPLICATION_PUBLISH_FOLDER }} -p:Version=0.0.0
- name: Show content for debug
if: ${{ env.DEBUG == 'true' }}
run: ls
Expand Down Expand Up @@ -163,11 +150,11 @@ jobs:
cd ./$RELEASE_ARTIFACT_FOLDER/$WINDOWS_ARTIFACT_NAME
zip -r $WINDOWS_ARTIFACT_NAME.zip ./*
mv $WINDOWS_ARTIFACT_NAME.zip ../
rmdir -rf ./$WINDOWS_ARTIFACT_NAME
rm -rf ./../$WINDOWS_ARTIFACT_NAME
- name: Move nuget tool
run: |
mv ./$RELEASE_ARTIFACT_FOLDER/WINDOWS_NUGET_ARTIFACT_NAME/IL2CareerToolset*.nupkg ./$RELEASE_ARTIFACT_FOLDER
rmdir rmdir -rf ./$RELEASE_ARTIFACT_FOLDER/WINDOWS_NUGET_ARTIFACT_NAME/
mv ./$RELEASE_ARTIFACT_FOLDER/$WINDOWS_NUGET_ARTIFACT_NAME/IL2CareerToolset*.nupkg ./$RELEASE_ARTIFACT_FOLDER
rm -rf ./$RELEASE_ARTIFACT_FOLDER/$WINDOWS_NUGET_ARTIFACT_NAME/
- name: display artifacts folder content
if: ${{ env.DEBUG == 'true' }}
run: ls -la $RELEASE_ARTIFACT_FOLDER
Expand All @@ -177,7 +164,7 @@ jobs:
gh release create Develop-${{ GITHUB.RUN_NUMBER }} \
--title "${{ env.RELEASE_NAME }} [${{ GITHUB.RUN_NUMBER }}]" --target ${{ env.REF_CHECKOUT_BRANCH }} \
--generate-notes --prerelease ${parameters} --notes "Recent version of the develop branch, ready for testing" \
-d ${{ env.RELEASE_ARTIFACT_FOLDER }}/*.zip
-d ${{ env.RELEASE_ARTIFACT_FOLDER }}/*.*
- name: Create release and upload artifacts
if: ${{ env.DEBUG == 'false' }}
run: |
Expand Down