Merge pull request #6 from Micka2302/codex/add-tag_name-derivation-an… #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: Build | |
| on: | |
| push: | |
| branches: | |
| - main | |
| tags: | |
| - 'v*' | |
| pull_request: | |
| branches: | |
| - main | |
| release: | |
| types: [published] | |
| jobs: | |
| build: | |
| runs-on: ubuntu-latest | |
| outputs: | |
| tag_name: ${{ steps.set_tag_name.outputs.tag_name }} | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| - name: Determine TAG_NAME | |
| id: set_tag_name | |
| run: | | |
| if [ "${{ github.event_name }}" = "release" ]; then | |
| echo "TAG_NAME=${{ github.event.release.tag_name }}" >> "$GITHUB_ENV" | |
| echo "tag_name=${{ github.event.release.tag_name }}" >> "$GITHUB_OUTPUT" | |
| else | |
| echo "TAG_NAME=${{ github.ref_name }}" >> "$GITHUB_ENV" | |
| echo "tag_name=${{ github.ref_name }}" >> "$GITHUB_OUTPUT" | |
| fi | |
| - name: Setup .NET | |
| uses: actions/setup-dotnet@v3 | |
| with: | |
| dotnet-version: 8.0.x | |
| - name: Restore dependencies | |
| run: dotnet restore | |
| - name: Build | |
| run: dotnet build --configuration Release BetterWho.csproj | |
| - name: Prepare artifacts | |
| run: | | |
| mkdir -p addons/counterstrikesharp/plugins/BetterWho | |
| mkdir -p addons/counterstrikesharp/configs/plugins/BetterWho | |
| cp bin/Release/net8.0/BetterWho.dll addons/counterstrikesharp/plugins/BetterWho/BetterWho.dll | |
| if [ -f configs/BetterWho.json ]; then | |
| cp configs/BetterWho.json addons/counterstrikesharp/configs/plugins/BetterWho/BetterWho.json | |
| fi | |
| - name: Package addon | |
| run: zip -r "BetterWho-${TAG_NAME}.zip" addons/ | |
| - name: Upload artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: BetterWho | |
| path: addons/ | |
| - name: Create GitHub Release | |
| if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/') | |
| uses: softprops/action-gh-release@v1 | |
| with: | |
| files: BetterWho-${{ env.TAG_NAME }}.zip | |
| release: | |
| needs: build | |
| permissions: write-all | |
| runs-on: ubuntu-latest | |
| if: github.event_name == 'release' | |
| steps: | |
| - name: Set TAG_NAME | |
| run: echo "TAG_NAME=${{ needs.build.outputs.tag_name }}" >> "$GITHUB_ENV" | |
| - name: Download artifact | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: BetterWho | |
| path: . | |
| - name: Zip release artifact | |
| run: | | |
| cd BetterWho | |
| zip -r "../BetterWho-${TAG_NAME}.zip" -i counterstriksharp/ | |
| - name: Get release upload URL | |
| id: release_info | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| run: | | |
| upload_url=$(curl -sSL \ | |
| -H "Authorization: Bearer $GITHUB_TOKEN" \ | |
| -H "Accept: application/vnd.github+json" \ | |
| "${{ github.event.release.url }}" | jq -r '.upload_url' | sed 's/{?name,label}//') | |
| echo "upload_url=$upload_url" >> "$GITHUB_OUTPUT" | |
| - name: Upload release asset | |
| uses: actions/upload-release-asset@v1 | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| with: | |
| upload_url: ${{ steps.release_info.outputs.upload_url }} | |
| asset_path: BetterWho-${{ env.TAG_NAME }}.zip | |
| asset_name: cs2-betterwho-${{ env.TAG_NAME }}.zip | |
| asset_content_type: application/zip |