Merge pull request #7 from blbrdv/fixes/cicd #15
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Release | |
| on: | |
| workflow_dispatch: | |
| push: | |
| branches: | |
| - 'main' | |
| paths: | |
| - '.github/workflows/release.yaml' | |
| - '.github/workflows/build-project.yaml' | |
| - '.nuke/**' | |
| - 'build/**' | |
| - 'dist/**' | |
| - 'src/**' | |
| - 'Aegir.sln' | |
| - 'run.*' | |
| - 'global.json' | |
| env: | |
| ContinuousIntegrationBuild: true | |
| Game: valheim | |
| Name: Aegir | |
| jobs: | |
| check-tag: | |
| runs-on: windows-latest | |
| name: Check release tag existence | |
| outputs: | |
| tag: ${{ steps.check.outputs.tag }} | |
| version: ${{ steps.check.outputs.version }} | |
| steps: | |
| - uses: actions/checkout@v6 | |
| - name: Checking tag | |
| id: check | |
| env: | |
| GH_TOKEN: ${{ github.token }} | |
| run: | | |
| $XML = [Xml] (Get-Content ${{ github.workspace }}\src\${{ env.Name }}.csproj); | |
| $CurrentVersion = [Version] $XML.Project.PropertyGroup.Version; | |
| echo "Current version: $CurrentVersion"; | |
| echo "Current tag: v$CurrentVersion"; | |
| echo "tag=v$CurrentVersion" >> $env:GITHUB_OUTPUT; | |
| echo "version=$CurrentVersion" >> $env:GITHUB_OUTPUT; | |
| $Response = gh api ` | |
| -H "Accept: application/vnd.github+json" ` | |
| -H "X-GitHub-Api-Version: 2022-11-28" ` | |
| /repos/blbrdv/${{ env.Name }}/tags ` | |
| | ConvertFrom-Json; | |
| foreach ($Tag in $Response) { | |
| if ($Tag.name -eq "v$CurrentVersion") { | |
| echo "Tag 'v$CurrentVersion' already exists. Update project version."; | |
| exit 1; | |
| } | |
| } | |
| build: | |
| needs: check-tag | |
| name: Build project | |
| uses: ./.github/workflows/build-project.yaml | |
| with: | |
| target-ref: 'main' | |
| github-release: | |
| needs: [ build, check-tag ] | |
| name: Github release | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write | |
| outputs: | |
| changes: ${{ steps.changelog_reader.outputs.changes }} | |
| steps: | |
| - uses: actions/checkout@v6 | |
| - name: Download project artefact | |
| uses: actions/download-artifact@v5 | |
| with: | |
| name: plugin-${{ github.sha }} | |
| - name: Parse changelog | |
| id: changelog_reader | |
| uses: mindsers/changelog-reader-action@v2 | |
| with: | |
| validation_level: warn | |
| version: ${{ needs.check-tag.outputs.version }} | |
| path: ${{ github.workspace }}/CHANGELOG.md | |
| - name: GitHub release | |
| uses: ncipollo/release-action@v1 | |
| with: | |
| tag: ${{ needs.check-tag.outputs.tag }} | |
| body: ${{ steps.changelog_reader.outputs.changes }} | |
| token: ${{ secrets.GITHUB_TOKEN }} | |
| allowUpdates: false | |
| artifacts: ${{ github.workspace }}/${{ env.Name }}.dll | |
| nexusmods-release: | |
| needs: [ github-release, check-tag ] | |
| name: NexusMods release | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v6 | |
| - name: Dotnet restore | |
| uses: ./.github/actions/restore | |
| - name: Download project artefact | |
| uses: actions/download-artifact@v5 | |
| with: | |
| name: plugin-${{ github.sha }} | |
| path: ${{ github.workspace }}/src/bin/Release/net46 | |
| - name: Pack artifacts | |
| run: ./run.sh PackForNexusmods | |
| - name: Upload to NexusMods | |
| uses: hmlendea/nexusmods-update@latest | |
| with: | |
| account_email_address: ${{ secrets.NEXUS_EMAIL_ADDRESS }} | |
| account_password: ${{ secrets.NEXUS_PASSWORD }} | |
| nexus_game_id: ${{ env.Game }} | |
| nexus_mod_id: 2400 | |
| mod_file_name: ${{ env.Name }} | |
| mod_version: ${{ needs.check-tag.outputs.version }} | |
| file_description: ${{ needs.github-release.outputs.changes }} | |
| file_path: ${{ github.workspace }}/output/NexusMods/${{ env.Name }}-${{ needs.check-tag.outputs.version }}.zip | |
| thunderstore-release: | |
| needs: [ github-release, check-tag ] | |
| name: ThunderStore release | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v6 | |
| - name: Dotnet restore | |
| uses: ./.github/actions/restore | |
| - name: Download build artefacts | |
| uses: actions/download-artifact@v5 | |
| with: | |
| name: plugin-${{ github.sha }} | |
| path: ${{ github.workspace }}/src/bin/Release/net46 | |
| - name: Pack artifacts | |
| run: ./run.sh PackForThunderstore | |
| - name: Upload mod to ThunderStore | |
| uses: dhkatz/thunderstore-publish@v1.0.1 | |
| id: publish | |
| with: | |
| token: ${{ secrets.THUNDERSTORE_TOKEN }} | |
| namespace: blbrdv | |
| name: ${{ env.Name }} | |
| description: Simple mod for disabling water camera clipping | |
| version: ${{ needs.check-tag.outputs.version }} | |
| communities: ${{ env.Game }} | |
| categories: | | |
| mods | |
| misc | |
| client-side | |
| file: ${{ github.workspace }}/output/ThunderStore/${{ env.Name }}-${{ needs.check-tag.outputs.version }}.zip |