From e54420aea219d26b5ccb0d043785ab12481a4ea5 Mon Sep 17 00:00:00 2001 From: hazre <37149950+hazre@users.noreply.github.com> Date: Fri, 29 Aug 2025 20:05:50 +0200 Subject: [PATCH] Add build and release workflows --- .github/workflows/build.yml | 43 ++++++++++++++++++++ .github/workflows/release.yml | 76 +++++++++++++++++++++++++++++++++++ BepisLocaleLoader.csproj | 10 +++++ 3 files changed, 129 insertions(+) create mode 100644 .github/workflows/build.yml create mode 100644 .github/workflows/release.yml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..d54d31a --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,43 @@ +name: Build + +on: + push: + branches: [ '**' ] + pull_request: + branches: [ '**' ] + workflow_dispatch: + +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + with: + fetch-depth: 0 # Need to fetch all for proper history + - name: Collect build info + id: info + run: | + # Get short SHA + SHA_SHORT=$(git rev-parse --short HEAD) + echo "sha_short=$SHA_SHORT" >> $GITHUB_OUTPUT + + # Extract version from csproj + VERSION=$(grep -oP '(?<=)[^<]+' BepisLocaleLoader.csproj) + echo "version=$VERSION" >> $GITHUB_OUTPUT + echo "Version found: $VERSION" + - uses: actions/setup-dotnet@v4 + with: + dotnet-version: "9.0.x" + - name: Build + run: | + dotnet build -c Release + dotnet pack -c Release --no-build -o ./bin/dist + # Copy the built DLL to dist folder + cp ./bin/Release/BepisLocaleLoader.dll ./bin/dist/ + - name: Upload artifacts + uses: actions/upload-artifact@v4 + with: + name: BepisLocaleLoader-${{ steps.info.outputs.version }}-${{ steps.info.outputs.sha_short }} + path: | + ./bin/dist/*.nupkg + ./bin/dist/*.dll \ No newline at end of file diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..1889e67 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,76 @@ +name: Release + +on: + push: + tags: + - 'v*' + workflow_dispatch: + inputs: + create_release: + description: 'Create a GitHub release' + required: false + default: 'true' + type: choice + options: + - 'true' + - 'false' + +jobs: + release: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + with: + fetch-depth: 0 # Need to fetch all for proper history + - name: Collect build info + id: info + run: | + # Get short SHA + SHA_SHORT=$(git rev-parse --short HEAD) + echo "sha_short=$SHA_SHORT" >> $GITHUB_OUTPUT + + # Extract version from csproj + VERSION=$(grep -oP '(?<=)[^<]+' BepisLocaleLoader.csproj) + echo "version=$VERSION" >> $GITHUB_OUTPUT + echo "Version found: $VERSION" + - uses: actions/setup-dotnet@v4 + with: + dotnet-version: "9.0.x" + - name: Build + run: | + dotnet build -c Release + dotnet pack -c Release --no-build -o ./bin/dist + # Copy the built DLL to dist folder for release + cp ./bin/Release/BepisLocaleLoader.dll ./bin/dist/ + - name: Create Git Tag (if needed) + if: ${{ github.event_name == 'workflow_dispatch' }} + run: | + TAG_NAME="${{ steps.info.outputs.version }}" + # Check if tag already exists + if git rev-parse "$TAG_NAME" >/dev/null 2>&1; then + echo "Tag $TAG_NAME already exists" + else + echo "Creating tag $TAG_NAME" + git config user.name github-actions + git config user.email github-actions@github.com + git tag -a "$TAG_NAME" -m "Release $TAG_NAME" + git push origin "$TAG_NAME" + fi + - name: Publish to Nuget + run: | + dotnet nuget push ./bin/dist/*.nupkg --api-key ${{ secrets.NUGET_API_KEY }} --source https://nuget-modding.resonite.net/v3/index.json --skip-duplicate + - name: Create GitHub Release + if: ${{ (github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')) || (github.event_name == 'workflow_dispatch' && github.event.inputs.create_release == 'true') }} + uses: softprops/action-gh-release@v2 + with: + draft: true + prerelease: false + generate_release_notes: false + name: ${{ steps.info.outputs.version }} + tag_name: ${{ steps.info.outputs.version }} + target_commitish: ${{ github.sha }} + files: | + ./bin/dist/*.nupkg + ./bin/dist/*.dll + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file diff --git a/BepisLocaleLoader.csproj b/BepisLocaleLoader.csproj index 061a0fd..fb37c8e 100644 --- a/BepisLocaleLoader.csproj +++ b/BepisLocaleLoader.csproj @@ -4,7 +4,9 @@ 1.0.0 NepuShiro net9.0 + https://github.com/ResoniteModding/BepisLocaleLoader https://github.com/ResoniteModding/BepisLocaleLoader + git ResoniteModding.BepisLocaleLoader Bepis Locale Loader BepisLocaleLoader @@ -13,6 +15,9 @@ true false true + true + true + embedded $(ResonitePath)/ $(MSBuildProgramFiles32)\Steam\steamapps\common\Resonite\ $(HOME)/.steam/steam/steamapps/common/Resonite/ @@ -24,6 +29,7 @@ + @@ -68,4 +74,8 @@ + + + true +