Skip to content

Commit

Permalink
Merge pull request #50 from Rune580/Refactor-Build
Browse files Browse the repository at this point in the history
Refactor Build
  • Loading branch information
Rune580 authored Jun 8, 2024
2 parents 603b7c7 + 4e5cd9f commit ee4385d
Show file tree
Hide file tree
Showing 34 changed files with 316 additions and 837 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"
]
}
}
}
5 changes: 0 additions & 5 deletions .env.example

This file was deleted.

47 changes: 19 additions & 28 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,41 +1,32 @@

name: Build

on:
pull_request:
branches: [ master, main ]
push:
branches: [ master, main ]
branches: [ master ]
pull_request:

jobs:
build:
runs-on: ubuntu-latest
env:
USE_STUBBED_LIBS: 1
steps:
- name: Checkout Repo
uses: actions/checkout@v3

- name: Output Short Sha Commit
run: |
export SHORT_SHA=$(git rev-parse --short ${{ github.sha }})
echo "RELEASE_VERSION=${{ github.event_name == 'pull_request' && github.head_ref || github.ref_name }}-${SHORT_SHA}" >> "$GITHUB_ENV"
shell: bash
- name: Checkout Repo
uses: actions/checkout@v4

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

- name: Grant execute permissions for build script
run: chmod +x build.sh
- name: Restore project
run: |
dotnet restore
dotnet tool restore
- name: Build
run: ./build.sh --configuration=Release --target=BuildThunderstore
- name: Build project
run: dotnet build -c Release

- name: Upload artifacts
uses: actions/upload-artifact@v3
with:
name: input-utils
path: LethalCompanyInputUtils/bin/Release/netstandard2.1/upload/
retention-days: 30
- name: Upload Artifacts
uses: actions/upload-artifact@v4
with:
name: build-artifacts
path: ./dist/*.zip
215 changes: 134 additions & 81 deletions .github/workflows/release-tags.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,89 +11,142 @@ permissions:

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:
USE_STUBBED_LIBS: 1
RELEASE_VERSION: ${{ github.ref_name }}
steps:
- name: Checkout Repo
uses: actions/checkout@v3

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

- name: Grant execute permissions for build script
run: chmod +x build.sh

- name: Build Thunderstore Package
run: ./build.sh --configuration=Release --target=BuildThunderstore

- name: Build NuGet Package
run: ./build.sh --configuration=Release --target=BuildNuGet

- name: Upload artifacts
uses: actions/upload-artifact@v3
with:
name: input-utils
path: LethalCompanyInputUtils/bin/Release/netstandard2.1/upload/
retention-days: 30

- name: Setup NuGet Push Source
run: dotnet nuget add source --username USERNAME --password ${{ secrets.GITHUB_TOKEN }} --store-password-in-clear-text --name github "https://nuget.pkg.github.com/Rune580/index.json"

- name: Get NuGet Package path
run: |
for fn in LethalCompanyInputUtils/bin/Release/netstandard2.1/artifacts/*.nupkg; do echo "NUGET_PKG_PATH=${fn}" >> "$GITHUB_ENV"; done;
shell: bash
continue-on-error: true
- 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
env:
NUGET_API_TOKEN: ${{ secrets.NUGET_RELEASE_API_KEY }}
run: |
dotnet nuget push ./*/bin/Release/*.nupkg --api-key $NUGET_API_TOKEN --source https://api.nuget.org/v3/index.json
- name: Push NuGet Package (GitHub Packages)
run: dotnet nuget push "${NUGET_PKG_PATH}" --source "github"

- name: Push NuGet Package (nuget.org)
run: dotnet nuget push "${NUGET_PKG_PATH}" --api-key $NUGET_API_TOKEN --source https://api.nuget.org/v3/index.json
env:
NUGET_API_TOKEN: ${{ secrets.NUGET_RELEASE_API_KEY }}

- 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}" LethalCompanyInputUtils/bin/Release/netstandard2.1/upload/*.zip
shell: bash
continue-on-error: true
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Get upload file path
run: |
for fn in LethalCompanyInputUtils/bin/Release/netstandard2.1/upload/*.zip; do echo "THUNDERSTORE_PKG_PATH=${fn}" >> "$GITHUB_ENV"; done;
shell: bash
continue-on-error: true

- name: Upload Thunderstore Package
uses: GreenTF/[email protected]
with:
namespace: Rune580
name: LethalCompany_InputUtils
description: Empty
version: ${{ github.ref_name }}
community: lethal-company
token: ${{ secrets.THUNDERSTORE_TOKEN }}
repo: thunderstore.io
categories: |
libraries
file: ${{ env.THUNDERSTORE_PKG_PATH }}
deploy-to-github-pkgs:
name: Deploy to GitHub Packages
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: Setup NuGet Push Source
run: dotnet nuget add source --username USERNAME --password ${{ secrets.GITHUB_TOKEN }} --store-password-in-clear-text --name github "https://nuget.pkg.github.com/Rune580/index.json"

- name: Publish to GitHub Packages
run: |
dotnet nuget push ./*/bin/Release/*.nupkg --source "github"
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 @@ -7,4 +7,6 @@ riderModule.iml
.idea/
**.user

.env
.env

dist/
9 changes: 2 additions & 7 deletions LethalCompanyInputUtils.sln
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,12 @@
Microsoft Visual Studio Solution File, Format Version 12.00
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LethalCompanyInputUtils", "LethalCompanyInputUtils\LethalCompanyInputUtils.csproj", "{94E68A23-78B8-4D27-BCA6-B14C238F9D67}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "build", "build\Build.csproj", "{566DD797-F558-4E46-92A7-31080C736C97}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{C126025D-A702-4C8C-840F-85F8AD98A91D}"
ProjectSection(SolutionItems) = preProject
build-settings.json = build-settings.json
.env = .env
manifest.json = manifest.json
READEME.md = README.md
README.md = README.md
CHANGELOG.md = CHANGELOG.md
thunderstore.toml = Thunderstore/thunderstore.toml
EndProjectSection
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LethalCompanyInputUtils.SourceGen", "LethalCompanyInputUtils.SourceGen\LethalCompanyInputUtils.SourceGen.csproj", "{D0544F61-1C64-44A0-A2BB-6DC53C41F2A2}"
Expand All @@ -21,8 +18,6 @@ Global
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{566DD797-F558-4E46-92A7-31080C736C97}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{566DD797-F558-4E46-92A7-31080C736C97}.Release|Any CPU.ActiveCfg = Release|Any CPU
{94E68A23-78B8-4D27-BCA6-B14C238F9D67}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{94E68A23-78B8-4D27-BCA6-B14C238F9D67}.Debug|Any CPU.Build.0 = Debug|Any CPU
{94E68A23-78B8-4D27-BCA6-B14C238F9D67}.Release|Any CPU.ActiveCfg = Release|Any CPU
Expand Down
Loading

0 comments on commit ee4385d

Please sign in to comment.