mkv

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README

ci.yaml (2917B)


      1 name: "CI"
      2 
      3 on:
      4   push:
      5     branches: ["main"]
      6     tags: ["v*"]
      7   pull_request:
      8     branches: ["main"]
      9 
     10 jobs:
     11   test:
     12     name: Run tests
     13     runs-on: native
     14     steps:
     15       - uses: actions/checkout@v4
     16       - name: Run unit tests
     17         run: nix build --print-build-logs .#checks.x86_64-linux.default
     18 
     19   build:
     20     name: Build ${{ matrix.target }}
     21     runs-on: native
     22     strategy:
     23       fail-fast: false
     24       matrix:
     25         include:
     26           - package: x86_64-linux
     27             target: x86_64-unknown-linux-gnu
     28           # - package: x86_64-linux-musl
     29           #   target: x86_64-unknown-linux-musl
     30           # - package: aarch64-linux
     31           #   target: aarch64-unknown-linux-gnu
     32           # - package: default
     33           #   target: x86_64-apple-darwin
     34           #   system: x86_64-darwin
     35           # - package: default
     36           #   target: aarch64-apple-darwin
     37           #   system: aarch64-darwin
     38     steps:
     39       - uses: actions/checkout@v4
     40 
     41       - name: Build
     42         run: nix build --print-build-logs .#packages.x86_64-linux.${{ matrix.package }}
     43 
     44       - name: Prepare release artifact
     45         if: startsWith(forgejo.ref, 'refs/tags/')
     46         run: cp result/bin/mkv mkv-${{ matrix.target }}
     47 
     48       - name: Upload artifact
     49         if: startsWith(forgejo.ref, 'refs/tags/')
     50         uses: actions/upload-artifact@v3
     51         with:
     52           name: mkv-${{ matrix.target }}
     53           path: mkv-${{ matrix.target }}
     54 
     55   release:
     56     name: Create release
     57     needs: [test, build]
     58     runs-on: native
     59     if: startsWith(forgejo.ref, 'refs/tags/')
     60     steps:
     61       - uses: actions/download-artifact@v3
     62         with:
     63           path: artifacts
     64 
     65       - name: Collect artifacts
     66         run: |
     67           mkdir -p release
     68           find artifacts -type f -name 'mkv-*' -exec mv {} release/ \;
     69           ls -la release/
     70 
     71       - name: Create release
     72         run: |
     73           tag="${GITHUB_REF#refs/tags/}"
     74           curl -X POST \
     75             -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
     76             -H "Content-Type: application/json" \
     77             -d "{\"tag_name\": \"${tag}\", \"name\": \"${tag}\"}" \
     78             "${{ env.GITHUB_SERVER_URL }}/api/v1/repos/${{ github.repository }}/releases"
     79           release_id=$(curl -s \
     80             -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
     81             "${{ env.GITHUB_SERVER_URL }}/api/v1/repos/${{ github.repository }}/releases/tags/${tag}" \
     82             | jq -r '.id')
     83           for file in release/*; do
     84             curl -X POST \
     85               -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
     86               -H "Content-Type: application/octet-stream" \
     87               --data-binary "@${file}" \
     88               "${{ env.GITHUB_SERVER_URL }}/api/v1/repos/${{ github.repository }}/releases/${release_id}/assets?name=$(basename $file)"
     89           done