diff --git a/.github/workflows/tag-and-release.yml b/.github/workflows/tag-and-release.yml new file mode 100644 index 0000000..3840a37 --- /dev/null +++ b/.github/workflows/tag-and-release.yml @@ -0,0 +1,101 @@ +name: Build and Release + +on: + push: + tags: + - 'v*' + workflow_dispatch: + +jobs: + build: + runs-on: ubuntu-latest + + strategy: + matrix: + os: [ubuntu-latest, windows-latest] + + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Setup .NET + uses: actions/setup-dotnet@v4 + with: + dotnet-version: 8.x + + - name: Install dependencies + run: dotnet restore + + - name: Publish application + run: | + if [ ${{ matrix.os }} == "ubuntu-latest" ]; then + echo "PUBLISHING FOR LINUX" + dotnet publish -c Release -r linux-x64 /p:PublishSingleFile=true /p:IncludeNativeLibrariesForSelfExtract=true --self-contained true + else + echo "PUBLISHING FOR WINDOWS" + dotnet publish -c Release -r win-x64 /p:PublishSingleFile=true /p:IncludeNativeLibrariesForSelfExtract=true --self-contained true + fi + + - name: Create ZIP file + run: | + if [ ${{ matrix.os }} == "ubuntu-latest" ]; then + zip -r --junk-paths FikaServerTools_${{ github.ref_name }}-linux64.zip ./bin/Release/net8.0/linux-x64/publish/ + else + zip -r --junk-paths FikaServerTools_${{ github.ref_name }}-windows64.zip ./bin/Release/net8.0/win-x64/publish/ + fi + shell: bash + + - name: Upload artifact + uses: actions/upload-artifact@v4 + with: + name: FikaServerTools_${{ matrix.os }}_${{ github.ref_name }} + path: FikaServerTools_${{ github.ref_name }}-*.zip + + release: + needs: build + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Download artifacts (Linux) + uses: actions/download-artifact@v4 + with: + name: FikaServerTools_ubuntu-latest_${{ github.ref_name }} + path: ./dist/linux + - name: Download artifacts (Windows) + uses: actions/download-artifact@v4 + with: + name: FikaServerTools_windows-latest_${{ github.ref_name }} + path: ./dist/windows + + - name: Create release + id: create_release + uses: Rohit-Kuinkel/create-release-node-update@main + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + tag_name: ${{ github.ref_name }} + release_name: "Fika-ServerTools ${{ github.ref_name }}" + prerelease: true + + - name: Upload Linux build + uses: Rohit-Kuinkel/upload-release-asset-node-update@main + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + upload_url: ${{ steps.create_release.outputs.upload_url }} + asset_path: ./dist/linux/FikaServerTools_${{ github.ref_name }}-linux64.zip + asset_name: FikaServerTools_${{ github.ref_name }}-linux64.zip + asset_content_type: application/zip + + - name: Upload Windows build + uses: Rohit-Kuinkel/upload-release-asset-node-update@main + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + upload_url: ${{ steps.create_release.outputs.upload_url }} + asset_path: ./dist/windows/FikaServerTools_${{ github.ref_name }}-windows64.zip + asset_name: FikaServerTools_${{ github.ref_name }}-windows64.zip + asset_content_type: application/zip