ci: refactor jobs into a single job with matrix

This commit is contained in:
Aikawa Yataro 2024-08-02 13:03:50 +00:00
parent b5d7f6d7ce
commit a76d18c668
No known key found for this signature in database
GPG key ID: 1C5D95FB10179404

View file

@ -1,107 +1,32 @@
name: Continuous Integration name: Continuous Integration
on: on:
push: push:
branches: branches: [develop]
- develop
pull_request: pull_request:
branches: [develop] branches: [develop]
workflow_dispatch: workflow_dispatch:
jobs: jobs:
build-windows: build:
name: Build Windows x64 strategy:
runs-on: windows-2019 matrix:
steps: include:
- name: Checkout sources - name : Windows x64
uses: actions/checkout@v4 os: windows-2019
with: runtime: win-x64
fetch-depth: 0 - name : macOS (Intel)
- name: Setup .NET os: macos-13
uses: actions/setup-dotnet@v4 runtime: osx-x64
with: - name : macOS (Apple Silicon)
dotnet-version: 8.0.x os: macos-latest
- name: Build runtime: osx-arm64
run: dotnet build -c Release - name : Linux
- name: Publish os: ubuntu-20.04
run: dotnet publish src/SourceGit.csproj -c Release -o publish -r win-x64 runtime: linux-x64
- name: Upload Artifact - name : Linux (arm64)
uses: actions/upload-artifact@v4 os: ubuntu-20.04
with: runtime: linux-arm64
name: sourcegit.win-x64 name: Build ${{ matrix.name }}
path: publish runs-on: ${{ matrix.os }}
build-macos-intel:
name: Build macOS (Intel)
runs-on: macos-13
steps:
- name: Checkout sources
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: 8.0.x
- name: Build
run: dotnet build -c Release
- name: Publish
run: dotnet publish src/SourceGit.csproj -c Release -o publish -r osx-x64
- name: Packing Program
run: tar -cvf sourcegit.osx-x64.tar -C publish/ .
- name: Upload Artifact
uses: actions/upload-artifact@v4
with:
name: sourcegit.osx-x64
path: sourcegit.osx-x64.tar
build-macos-arm64:
name: Build macOS (Apple Silicon)
runs-on: macos-latest
steps:
- name: Checkout sources
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: 8.0.x
- name: Build
run: dotnet build -c Release
- name: Publish
run: dotnet publish src/SourceGit.csproj -c Release -o publish -r osx-arm64
- name: Packing Program
run: tar -cvf sourcegit.osx-arm64.tar -C publish/ .
- name: Upload Artifact
uses: actions/upload-artifact@v4
with:
name: sourcegit.osx-arm64
path: sourcegit.osx-arm64.tar
build-linux:
name: Build Linux
runs-on: ubuntu-20.04
steps:
- name: Checkout sources
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: 8.0.x
- name: Build
run: dotnet build -c Release
- name: Publish
run: dotnet publish src/SourceGit.csproj -c Release -o publish -r linux-x64
- name: Rename Executable File
run: mv publish/SourceGit publish/sourcegit
- name: Packing Program
run: tar -cvf sourcegit.linux-x64.tar -C publish/ .
- name: Upload Artifact
uses: actions/upload-artifact@v4
with:
name: sourcegit.linux-x64
path: sourcegit.linux-x64.tar
build-linux-arm64:
name: Build Linux (arm64)
runs-on: ubuntu-20.04
steps: steps:
- name: Checkout sources - name: Checkout sources
uses: actions/checkout@v4 uses: actions/checkout@v4
@ -112,6 +37,7 @@ jobs:
with: with:
dotnet-version: 8.0.x dotnet-version: 8.0.x
- name: Configure arm64 packages - name: Configure arm64 packages
if: ${{ matrix.runtime == 'linux-arm64' }}
run: | run: |
sudo dpkg --add-architecture arm64 sudo dpkg --add-architecture arm64
echo 'deb [arch=arm64] http://ports.ubuntu.com/ubuntu-ports/ focal main restricted echo 'deb [arch=arm64] http://ports.ubuntu.com/ubuntu-ports/ focal main restricted
@ -121,19 +47,22 @@ jobs:
sudo sed -i -e 's/^deb http/deb [arch=amd64] http/g' /etc/apt/sources.list sudo sed -i -e 's/^deb http/deb [arch=amd64] http/g' /etc/apt/sources.list
sudo sed -i -e 's/^deb mirror/deb [arch=amd64] mirror/g' /etc/apt/sources.list sudo sed -i -e 's/^deb mirror/deb [arch=amd64] mirror/g' /etc/apt/sources.list
- name: Install cross-compiling dependencies - name: Install cross-compiling dependencies
if: ${{ matrix.runtime == 'linux-arm64' }}
run: | run: |
sudo apt-get update sudo apt-get update
sudo apt-get install clang llvm gcc-aarch64-linux-gnu zlib1g-dev:arm64 sudo apt-get install clang llvm gcc-aarch64-linux-gnu zlib1g-dev:arm64
- name: Build - name: Build
run: dotnet build -c Release run: dotnet build -c Release
- name: Publish - name: Publish
run: dotnet publish src/SourceGit.csproj -c Release -o publish -r linux-arm64 run: dotnet publish src/SourceGit.csproj -c Release -o publish -r ${{ matrix.runtime }}
- name: Rename Executable File - name: Rename executable file
if: ${{ startsWith(matrix.runtime, 'linux-') }}
run: mv publish/SourceGit publish/sourcegit run: mv publish/SourceGit publish/sourcegit
- name: Packing Program - name: Package program
run: tar -cvf sourcegit.linux-arm64.tar -C publish/ . if: ${{ ! startsWith(matrix.runtime, 'win-') }}
- name: Upload Artifact run: tar -cvf sourcegit.${{ matrix.runtime }}.tar -C publish/ .
- name: Upload artifact
uses: actions/upload-artifact@v4 uses: actions/upload-artifact@v4
with: with:
name: sourcegit.linux-arm64 name: sourcegit.${{ matrix.runtime }}
path: sourcegit.linux-arm64.tar path: ${{ startsWith(matrix.runtime, 'win-') && 'publish' || format('sourcegit.{0}.tar', matrix.runtime) }}