89 lines
2.8 KiB
YAML
89 lines
2.8 KiB
YAML
name: "CI"
|
|
|
|
on:
|
|
push:
|
|
branches: ["main"]
|
|
tags: ["v*"]
|
|
pull_request:
|
|
branches: ["main"]
|
|
|
|
jobs:
|
|
test:
|
|
name: Run tests
|
|
runs-on: native
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
- name: Run unit tests
|
|
run: nix build --print-build-logs .#checks.x86_64-linux.default
|
|
|
|
build:
|
|
name: Build ${{ matrix.target }}
|
|
runs-on: native
|
|
strategy:
|
|
fail-fast: false
|
|
matrix:
|
|
include:
|
|
- package: x86_64-linux
|
|
target: x86_64-unknown-linux-gnu
|
|
# - package: x86_64-linux-musl
|
|
# target: x86_64-unknown-linux-musl
|
|
# - package: aarch64-linux
|
|
# target: aarch64-unknown-linux-gnu
|
|
# - package: default
|
|
# target: x86_64-apple-darwin
|
|
# system: x86_64-darwin
|
|
# - package: default
|
|
# target: aarch64-apple-darwin
|
|
# system: aarch64-darwin
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
|
|
- name: Build
|
|
run: nix build --print-build-logs .#packages.x86_64-linux.${{ matrix.package }}
|
|
|
|
- name: Prepare release artifact
|
|
if: startsWith(forgejo.ref, 'refs/tags/')
|
|
run: cp result/bin/mkv mkv-${{ matrix.target }}
|
|
|
|
- name: Upload artifact
|
|
if: startsWith(forgejo.ref, 'refs/tags/')
|
|
uses: actions/upload-artifact@v3
|
|
with:
|
|
name: mkv-${{ matrix.target }}
|
|
path: mkv-${{ matrix.target }}
|
|
|
|
release:
|
|
name: Create release
|
|
needs: [test, build]
|
|
runs-on: native
|
|
if: startsWith(forgejo.ref, 'refs/tags/')
|
|
steps:
|
|
- uses: actions/download-artifact@v3
|
|
with:
|
|
path: artifacts
|
|
|
|
- name: Collect artifacts
|
|
run: |
|
|
mkdir -p release
|
|
find artifacts -type f -name 'mkv-*' -exec mv {} release/ \;
|
|
ls -la release/
|
|
|
|
- name: Create release
|
|
run: |
|
|
tag="${GITHUB_REF#refs/tags/}"
|
|
curl -X POST \
|
|
-H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
|
|
-H "Content-Type: application/json" \
|
|
-d "{\"tag_name\": \"${tag}\", \"name\": \"${tag}\"}" \
|
|
"${{ env.GITHUB_SERVER_URL }}/api/v1/repos/${{ github.repository }}/releases"
|
|
release_id=$(curl -s \
|
|
-H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
|
|
"${{ env.GITHUB_SERVER_URL }}/api/v1/repos/${{ github.repository }}/releases/tags/${tag}" \
|
|
| jq -r '.id')
|
|
for file in release/*; do
|
|
curl -X POST \
|
|
-H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
|
|
-H "Content-Type: application/octet-stream" \
|
|
--data-binary "@${file}" \
|
|
"${{ env.GITHUB_SERVER_URL }}/api/v1/repos/${{ github.repository }}/releases/${release_id}/assets?name=$(basename $file)"
|
|
done
|