|
| 1 | +################################################################################ |
| 2 | +### Build AsepriteDotNet (Release) |
| 3 | +### Builds, tests, and packs the AsepriteDotNet source libraries. |
| 4 | +### Once the build job finishes, the deploy job uploads the nupkg files to NuGet. |
| 5 | +### |
| 6 | +### - Can be triggered manually with workflow_dispatch |
| 7 | +### - Allows specifying a branch (defaults to develop) |
| 8 | +### - Version numbers are determined by the project properties on the branch |
| 9 | +################################################################################ |
| 10 | +name: "Create Release" |
| 11 | + |
| 12 | +on: |
| 13 | + workflow_dispatch: |
| 14 | + inputs: |
| 15 | + branch: |
| 16 | + description: 'Branch to build from (e.g., main, develop)' |
| 17 | + required: true |
| 18 | + type: string |
| 19 | + default: 'develop' |
| 20 | + |
| 21 | +jobs: |
| 22 | + build: |
| 23 | + name: "Build AsepriteDotNet" |
| 24 | + runs-on: ubuntu-latest |
| 25 | + |
| 26 | + steps: |
| 27 | + - name: Clone Repository |
| 28 | + uses: actions/checkout@v4 |
| 29 | + with: |
| 30 | + ref: ${{ inputs.branch }} |
| 31 | + |
| 32 | + - name: Setup Dotnet |
| 33 | + uses: actions/setup-dotnet@v4 |
| 34 | + with: |
| 35 | + dotnet-version: 8.0.x |
| 36 | + |
| 37 | + - name: Build AsepriteDotNet |
| 38 | + run: dotnet build source/AsepriteDotNet/AsepriteDotNet.csproj --nologo --verbosity minimal --configuration Release |
| 39 | + |
| 40 | + - name: Test AsepriteDotNet |
| 41 | + run: dotnet test tests/AsepriteDotNet.Tests/AsepriteDotNet.Tests.csproj --nologo --verbosity minimal --configuration Release |
| 42 | + |
| 43 | + - name: Pack AsepriteDotNet |
| 44 | + run: dotnet pack source/AsepriteDotNet/AsepriteDotNet.csproj --nologo --verbosity minimal --configuration Release |
| 45 | + |
| 46 | + - name: Upload Artifacts |
| 47 | + uses: actions/upload-artifact@v4 |
| 48 | + with: |
| 49 | + name: build-artifacts |
| 50 | + path: ./.artifacts/src/**/*.nupkg |
| 51 | + |
| 52 | + deploy: |
| 53 | + name: "Deploy NuGets" |
| 54 | + runs-on: ubuntu-latest |
| 55 | + needs: [ build ] |
| 56 | + permissions: |
| 57 | + contents: write |
| 58 | + |
| 59 | + steps: |
| 60 | + - name: Download Artifacts |
| 61 | + uses: actions/download-artifact@v4 |
| 62 | + with: |
| 63 | + name: build-artifacts |
| 64 | + path: ./.artifacts |
| 65 | + |
| 66 | + - name: Push Packages to NuGet |
| 67 | + env: |
| 68 | + NUGET_API_KEY: ${{ secrets.NUGET_API_KEY }} |
| 69 | + run: | |
| 70 | + for PACKAGE in .artifacts/**/*.nupkg; do |
| 71 | + dotnet nuget push "$PACKAGE" --source https://api.nuget.org/v3/index.json --skip-duplicate --api-key "$NUGET_API_KEY" |
| 72 | + done |
0 commit comments