New CI/CD
This commit is contained in:
parent
8e6a96633a
commit
f72cc0c9aa
2 changed files with 76 additions and 89 deletions
76
.forgejo/workflows/ci.yaml
Normal file
76
.forgejo/workflows/ci.yaml
Normal file
|
|
@ -0,0 +1,76 @@
|
|||
name: "CI"
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: ["main"]
|
||||
tags: ["v*"]
|
||||
pull_request:
|
||||
branches: ["main"]
|
||||
|
||||
jobs:
|
||||
test:
|
||||
name: Test
|
||||
runs-on: native
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- name: Run unit tests
|
||||
run: nix develop --command cargo test --lib
|
||||
|
||||
build:
|
||||
name: Build ${{ matrix.package }}
|
||||
runs-on: native
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
package:
|
||||
- default
|
||||
- x86_64-linux-musl
|
||||
- aarch64-linux
|
||||
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: |
|
||||
target="${{ matrix.package }}"
|
||||
if [ "$target" = "default" ]; then
|
||||
target="x86_64-unknown-linux-gnu"
|
||||
elif [ "$target" = "x86_64-linux-musl" ]; then
|
||||
target="x86_64-unknown-linux-musl"
|
||||
elif [ "$target" = "aarch64-linux" ]; then
|
||||
target="aarch64-unknown-linux-gnu"
|
||||
fi
|
||||
cp result/bin/mkv "mkv-${target}"
|
||||
|
||||
- name: Upload artifact
|
||||
if: startsWith(forgejo.ref, 'refs/tags/')
|
||||
uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: mkv-${{ matrix.package }}
|
||||
path: mkv-*
|
||||
|
||||
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
|
||||
uses: actions/forgejo-release@v2
|
||||
with:
|
||||
direction: upload
|
||||
release-dir: release
|
||||
token: ${{ secrets.GITHUB_TOKEN }}
|
||||
89
.github/workflows/ci.yml
vendored
89
.github/workflows/ci.yml
vendored
|
|
@ -1,89 +0,0 @@
|
|||
name: "CI"
|
||||
on:
|
||||
pull_request:
|
||||
push:
|
||||
branches: ["main"]
|
||||
tags: ["v*"]
|
||||
permissions:
|
||||
contents: write
|
||||
|
||||
jobs:
|
||||
build-nix:
|
||||
name: Build ${{ matrix.target }}
|
||||
runs-on: ${{ matrix.runner }}
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
include:
|
||||
- target: x86_64-unknown-linux-gnu
|
||||
runner: ubuntu-latest
|
||||
system: x86_64-linux
|
||||
package: default
|
||||
- target: x86_64-unknown-linux-musl
|
||||
runner: ubuntu-latest
|
||||
system: x86_64-linux
|
||||
package: x86_64-linux-musl
|
||||
- target: aarch64-unknown-linux-gnu
|
||||
runner: ubuntu-latest
|
||||
system: x86_64-linux
|
||||
package: aarch64-linux
|
||||
- target: x86_64-apple-darwin
|
||||
runner: macos-13
|
||||
system: x86_64-darwin
|
||||
package: default
|
||||
- target: aarch64-apple-darwin
|
||||
runner: macos-latest
|
||||
system: aarch64-darwin
|
||||
package: default
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: DeterminateSystems/nix-installer-action@main
|
||||
|
||||
- run: nix --print-build-logs build .#packages.${{ matrix.system }}.${{ matrix.package }}
|
||||
|
||||
- name: Prepare release artifact
|
||||
if: startsWith(github.ref, 'refs/tags/')
|
||||
run: cp result/bin/mkv mkv-${{ matrix.target }}
|
||||
|
||||
- name: Upload artifact
|
||||
if: startsWith(github.ref, 'refs/tags/')
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: mkv-${{ matrix.target }}
|
||||
path: mkv-${{ matrix.target }}
|
||||
|
||||
build-windows:
|
||||
name: Build x86_64-pc-windows-msvc
|
||||
runs-on: windows-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: dtolnay/rust-toolchain@stable
|
||||
|
||||
- run: cargo build --release
|
||||
|
||||
- name: Prepare release artifact
|
||||
if: startsWith(github.ref, 'refs/tags/')
|
||||
run: cp target/release/mkv.exe mkv-x86_64-pc-windows-msvc.exe
|
||||
|
||||
- name: Upload artifact
|
||||
if: startsWith(github.ref, 'refs/tags/')
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: mkv-x86_64-pc-windows-msvc
|
||||
path: mkv-x86_64-pc-windows-msvc.exe
|
||||
|
||||
release:
|
||||
name: Create release
|
||||
needs: [build-nix, build-windows]
|
||||
runs-on: ubuntu-latest
|
||||
if: startsWith(github.ref, 'refs/tags/')
|
||||
steps:
|
||||
- uses: actions/download-artifact@v4
|
||||
with:
|
||||
path: artifacts
|
||||
merge-multiple: true
|
||||
|
||||
- name: Create release
|
||||
uses: softprops/action-gh-release@v2
|
||||
with:
|
||||
files: artifacts/*
|
||||
Loading…
Add table
Add a link
Reference in a new issue