Skip to content

Commit

Permalink
Merge pull request #34 from Rune580/build-system-refactor
Browse files Browse the repository at this point in the history
Refactor Build System
  • Loading branch information
Rune580 committed May 19, 2024
2 parents 8210adc + 90efd96 commit 9170a4b
Show file tree
Hide file tree
Showing 26 changed files with 453 additions and 1,148 deletions.
12 changes: 12 additions & 0 deletions .config/dotnet-tools.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"version": 1,
"isRoot": true,
"tools": {
"tcli": {
"version": "0.2.3",
"commands": [
"tcli"
]
}
}
}
32 changes: 32 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: Build

on:
push:
branches: [ main ]
pull_request:

jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout Repo
uses: actions/checkout@v4

- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: 8.0.x

- name: Restore project
run: |
dotnet restore
dotnet tool restore
- name: Build project
run: dotnet build -c Release

- name: Upload Artifacts
uses: actions/upload-artifact@v4
with:
name: build-artifacts
path: ./dist/*.zip
124 changes: 124 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
name: Publish

on:
push:
tags: [ 'v*' ]

permissions:
contents: write
packages: write

jobs:
build:
name: Build
runs-on: ubuntu-latest
steps:
- name: Checkout Repo
uses: actions/checkout@v4

- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: 8.0.x

- name: Restore project
run: |
dotnet restore
dotnet tool restore
- name: Build and pack project
run: dotnet pack -c Release

- name: Upload Thunderstore artifact
uses: actions/upload-artifact@v4
with:
name: thunderstore-build
path: ./dist/*.zip

- name: Upload nupkg artifact
uses: actions/upload-artifact@v4
with:
name: nupkg-build
path: ./*/bin/Release/*.nupkg

upload-release-artifacts:
name: Upload Release Artifacts
needs: build
runs-on: ubuntu-latest
env:
RELEASE_VERSION: ${{ github.ref_name }}
steps:
- name: Checkout Repo
uses: actions/checkout@v4

- name: Download artifacts
uses: actions/download-artifact@v4

- name: Delete old release if it already exists
run: gh release delete --yes "${RELEASE_VERSION}"
continue-on-error: true
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Release under current tag
run: |
export "CHANGELOG_FILE=$(mktemp --suffix=.md)"
echo "CHANGELOG_FILE=${CHANGELOG_FILE}" >> $GITHUB_ENV
gh api --method POST -H "Accept: application/vnd.github+json" \
"/repos/${GITHUB_REPOSITORY}/releases/generate-notes" \
-f tag_name="${RELEASE_VERSION}" \
--jq ".body" > "${CHANGELOG_FILE}"
cat "${CHANGELOG_FILE}"
gh release create "${RELEASE_VERSION}" -F "${CHANGELOG_FILE}" thunderstore-build/*.zip nupkg-build/*/bin/Release/*.nupkg
shell: bash
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

deploy-to-nuget:
name: Deploy to Nuget
needs: build
runs-on: ubuntu-latest
steps:
- name: Checkout Repo
uses: actions/checkout@v4

- name: Download nupkg artifact
uses: actions/download-artifact@v4
with:
name: nupkg-build

- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: 8.0.x

- name: Publish to NuGet.org
run: |
dotnet nuget push ./*/bin/Release/*.nupkg --api-key ${{ secrets.NUGET_API_TOKEN }} --source https://api.nuget.org/v3/index.json
deploy-to-thunderstore:
name: Deploy to Thunderstore
needs: build
runs-on: ubuntu-latest
steps:
- name: Checkout Repo
uses: actions/checkout@v4

- name: Download Thunderstore artifact
uses: actions/download-artifact@v4
with:
name: thunderstore-build

- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: 8.0.x

- name: Restore project tools
run: dotnet tool restore

- name: Publish to Thunderstore
env:
TCLI_AUTH_TOKEN: ${{ secrets.THUNDERSTORE_TOKEN }}
run: |
dotnet build -target:PublishThunderstoreArtifact
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -358,4 +358,6 @@ MigrationBackup/

global.json

.directory
.directory

dist/
6 changes: 0 additions & 6 deletions .nuke/parameters.json

This file was deleted.

1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

Loading

0 comments on commit 9170a4b

Please sign in to comment.