From 842d3050431d57b2453b95fff41c6269b6617069 Mon Sep 17 00:00:00 2001 From: "H. C. Kruse" Date: Sun, 26 Nov 2023 13:06:09 +0100 Subject: [PATCH] feat: Add automated build CI --- .github/workflows/build.yml | 96 +++++++++++++++++++++++++++++++++++++ .gitignore | 3 +- Loader/Loader.csproj | 2 +- 3 files changed, 98 insertions(+), 3 deletions(-) create mode 100644 .github/workflows/build.yml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 000000000..3200118c0 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,96 @@ +name: Build and Release + +on: + push: + branches: + - master + +jobs: + build: + runs-on: ubuntu-latest + + outputs: + tag: ${{ steps.tag.outputs.tag }} + + steps: + - name: Checkout Repository + uses: actions/checkout@v4 + + - name: Tag the repository + id: tag + run: | + git config user.name "GitHub Action" + git config user.email "foxftw@star-citizen.wiki" + # See https://docs.github.com/en/get-started/using-git/dealing-with-special-characters-in-branch-and-tag-names + TAG=$(echo ${GITHUB_SHA} | cut -c1-8) + echo "$TAG" + echo "tag=$TAG" >> $GITHUB_OUTPUT + git tag -a $TAG -m "Automated build on push: $TAG" ${GITHUB_SHA} + git push origin $TAG + + - name: Setup .NET + uses: actions/setup-dotnet@v3 + with: + dotnet-version: '8.x' + + - name: Restore dependencies + run: dotnet restore Loader + + - name: Build + run: dotnet build --configuration Release Loader + + - name: Publish Release + run: | + dotnet publish -c Release -o publish Loader + mkdir -p release + cp -r publish/* release/ + shell: bash + + build-windows: + runs-on: windows-latest + + steps: + - name: Checkout Repository + uses: actions/checkout@v4 + + - name: Setup .NET + uses: actions/setup-dotnet@v3 + with: + dotnet-version: '8.x' + + - name: Restore dependencies + run: dotnet restore Loader + + - name: Build + run: dotnet build --configuration Release Loader + + - name: Publish Release + run: | + dotnet publish -c Release -o publish-windows Loader + mkdir -p release-windows + cp -r publish-windows/* release-windows/ + shell: bash + + release: + needs: [ build, build-windows ] + runs-on: ubuntu-latest + + steps: + - uses: ncipollo/release-action@v1 + with: + artifacts: "release/*,release-windows/*" + body: "Automated build on push" + prerelease: true + tag: ${{ needs.build.outputs.tag }} +# - name: Create Release and Upload Asset +# uses: softprops/action-gh-release@v1 +# with: +# files: | +# release/* +# release-windows/* +# tag_name: ${{ needs.build.outputs.tag }} +# draft: false +# prerelease: true +# body: "Automated build on push" +# env: +# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.gitignore b/.gitignore index 18034c004..d56d464ee 100644 --- a/.gitignore +++ b/.gitignore @@ -3,10 +3,9 @@ obj packages .vscode Loader/.vs/ -.github api k8s website .idea redploy.bat -scunpacked.code-workspace \ No newline at end of file +scunpacked.code-workspace diff --git a/Loader/Loader.csproj b/Loader/Loader.csproj index 889ac923f..6cb7c92f9 100644 --- a/Loader/Loader.csproj +++ b/Loader/Loader.csproj @@ -2,7 +2,7 @@ Exe - netcoreapp7 + net8.0 true true