Skip to content

Commit

Permalink
CI: reduce work by reorganising workflows and reusing
Browse files Browse the repository at this point in the history
  • Loading branch information
Rjvs committed Sep 28, 2022
1 parent 9951d1b commit 178fc01
Show file tree
Hide file tree
Showing 4 changed files with 122 additions and 73 deletions.
76 changes: 76 additions & 0 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
name: Build

on:
workflow_call:
inputs:
project:
description: Name of the project (relatively short)
type: string
required: true

defaults:
run:
shell: bash

jobs:
build:
name: Build
runs-on: ${{ matrix.os }}
strategy:
matrix:
include:
- os: ubuntu-22.04
result: libsa.so
- os: macos-12
result: libsa.dylib
- os: windows-2022
result: bin/Release/sa.dll
fail-fast: false
env:
workingDir: build
finalDir: artifacts
defaults:
run:
shell: bash
steps:
- name: Checkout repo
uses: actions/checkout@v3
- name: Configure
id: cmake
run: |
mkdir $workingDir && cd $workingDir
cmd="cmake .."
case "${RUNNER_OS}" in
Linux) $cmd -DCMAKE_BUILD_TYPE=Release ;;
macOS) $cmd -DCMAKE_BUILD_TYPE=Release -DCMAKE_OSX_ARCHITECTURES="arm64;x86_64" ;;
Windows) $cmd -G "Visual Studio 17 2022" -A x64 -DCMAKE_CONFIGURATION_TYPES=Release ;;
*) echo "Do not recognise ${RUNNER_OS}." && exit 1 ;;
esac
- name: Build
working-directory: ${{ env.workingDir }}
run: |
cmd="cmake --build ."
case "${RUNNER_OS}" in
Linux) $cmd ;;
macOS) $cmd ;;
Windows) $cmd --config Release ;;
*) echo "Do not recognise ${RUNNER_OS}." && exit 1 ;;
esac
- name: Test
working-directory: ${{ env.workingDir }}
run: ctest
- name: Collect Files
run: |
mkdir $finalDir && cd $finalDir
cp $GITHUB_WORKSPACE/README.md .
cp $GITHUB_WORKSPACE/docs/SL.png .
cp $GITHUB_WORKSPACE/${{ env.workingDir }}/$lib .
ls -la
env:
lib: ${{ matrix.result }}
- uses: actions/upload-artifact@v3
name: Artifacts
with:
name: ${{ inputs.project }}-${{ runner.os }}
path: ${{ env.finalDir }}/*
if-no-files-found: error
52 changes: 30 additions & 22 deletions .github/workflows/deploy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,17 @@ defaults:

jobs:
metadata:
name: Collect Metadata
name: Collect
uses: StirlingLabs/.github/.github/workflows/metadata.yaml@main
with:
coreName: sa

build:
name: Collect Metadata
uses: ./.github/workflows/integrate.yaml
name: Build
needs: [ metadata ]
uses: ./.github/workflows/build.yaml
with:
project: ${{ needs.metadata.outputs.project }}

github:
name: GitHub Release
Expand Down Expand Up @@ -46,12 +49,19 @@ jobs:
-H 'Accept: application/vnd.github.v3.raw' \
-o artifacts/sa.h \
-L ${{ github.api_url }}/repos/${{ github.repository }}/contents/sa.h?ref=${{ github.ref_name }}
- name: Tar up files
id: tar
run: |
echo "::set-output name=filename::$filename"
tar czf $filename --directory=artifacts .
env:
filename: ${{ needs.metadata.outputs.project }}-${{ needs.metadata.outputs.fullVersion }}.tar.gz
- name: Create GitHub Release
uses: softprops/action-gh-release@v0.1.14
with:
name: libsa-${{ needs.metadata.outputs.fullVersion }}
name: ${{ needs.metadata.outputs.project }}-${{ needs.metadata.outputs.fullVersion }}
files: |
artifacts/**
${{ steps.tar.outputs.filename }}
nuget:
name: NuPkg Release
Expand All @@ -70,6 +80,11 @@ jobs:
runtime: win-x64
result: sa.dll
fail-fast: true
env:
platform: ${{ matrix.platform }}
runtime: ${{ matrix.runtime }}
result: ${{ matrix.result }}
project: ${{ needs.metadata.outputs.project }}
steps:
- name: Get Artifact
uses: actions/download-artifact@v3
Expand All @@ -79,8 +94,6 @@ jobs:

- name: Create NuSpec
run: |
ls -la
ls -la $platform
text="<?xml version=\"1.0\" encoding=\"utf-8\"?>"
text="$text\n<package xmlns=\"http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd\">"
text="$text\n <metadata>"
Expand All @@ -93,34 +106,29 @@ jobs:
text="$text\n </description>"
text="$text\n <authors>The Stirling Labs Team</authors>"
text="$text\n <projectUrl>$homepage</projectUrl>"
text="$text\n <readme>docs/Readme.md</readme>"
text="$text\n <readme>docs/README.md</readme>"
text="$text\n <icon>images/icon.png</icon>"
text="$text\n <tags>$project library SL sockets XP sockaddr StirlingLabs IP TCP UDP</tags>"
text="$text\n <license type=\"expression\">BSD-3-Clause</license>"
text="$text\n <tags>$project library SL sockets XP sockaddr StirlingLabs IP TCP UDP $topics</tags>"
text="$text\n <license type=\"expression\">$license</license>"
text="$text\n <requireLicenseAcceptance>true</requireLicenseAcceptance>"
text="$text\n <repository type=\"git\" url=\"$gitUrl\" branch=\"$branch\" commit=\"$commit\" />"
text="$text\n </metadata>"
text="$text\n <files>"
text="$text\n <file src=\"README.md\" target=\"docs/\" />"
text="$text\n <file src=\"docs/SL.png\" target=\"images/\" />"
text="$text\n <file src=\"$platform/$result\" target=\"runtimes/$runtime/native/\" />"
text="$text\n <file src=\"$runtime/README.md\" target=\"docs/README.md\" />"
text="$text\n <file src=\"$runtime/SL.png\" target=\"images/icon.png\" />"
text="$text\n <file src=\"$runtime/$result\" target=\"runtimes/$runtime/native/\" />"
text="$text\n </files>"
text="$text\n</package>"
echo -e $text > $project.nuspec
cat $project.nuspec
env:
platform: ${{ matrix.platform }}
runtime: ${{ matrix.runtime }}
result: ${{ matrix.result }}
project: ${{ needs.metadata.outputs.project }}
version: ${{ needs.metadata.outputs.fullVersion }}
homepage: ${{ needs.metadata.outputs.homepage }}
license: ${{ github.repository.license.spdx_id }}
gitUrl: ${{ github.repository.git_url }}
url: https://github.com/StirlingLabs/assimp
repo: ${{ github.repositoryUrl }}
license: MIT
gitUrl: ${{ github.event.repository.git_url }}
branch: ${{ needs.metadata.outputs.currentBranch }}
commit: ${{ github.sha }}
topics: ${{ needs.metadata.outputs.topics }}

- name: Create NuPkg
run: |
Expand All @@ -130,6 +138,6 @@ jobs:
- name: Upload NuPkg
run: |
dotnet nuget push *.nupkg -k ${{github.token}} -s https://nuget.pkg.github.com/${{github.repository_owner}}/index.json --no-symbols --skip-duplicate || true
# dotnet nuget push *.nupkg -k ${{secrets.NUGET_STIRLINGLABS_API_KEY}} -s https://api.nuget.org/v3/index.json --no-symbols --skip-duplicate
dotnet nuget push *.nupkg -k ${{secrets.NUGET_STIRLINGLABS_API_KEY}} -s https://api.nuget.org/v3/index.json --no-symbols --skip-duplicate
67 changes: 16 additions & 51 deletions .github/workflows/integrate.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,13 @@ defaults:

jobs:
skip_check:
name: Skip Run Check
name: Skip Check
uses: StirlingLabs/.github/.github/workflows/threshold.yaml@main

metadata:
name: Collect Metadata
name: Collect
needs: [ skip_check ]
if: needs.skip_check.outputs.continue == 'true'
uses: StirlingLabs/.github/.github/workflows/metadata.yaml@main
with:
coreName: sa
Expand All @@ -29,53 +31,16 @@ jobs:
name: Build
needs: [ skip_check, metadata ]
if: needs.skip_check.outputs.continue == 'true'
runs-on: ${{ matrix.os }}
strategy:
matrix:
include:
- os: ubuntu-22.04
result: libsa.so
- os: macos-12
result: libsa.dylib
- os: windows-2022
result: Release/sa.dll
fail-fast: false
env:
workingDir: build
finalDir: ${{ needs.metadata.outputs.project }}-${{ needs.metadata.outputs.significantVersion }}
defaults:
run:
shell: bash
uses: ./.github/workflows/build.yaml
with:
project: ${{ needs.metadata.outputs.project }}

list:
name: List Files
needs: build
runs-on: ubuntu-latest
if: needs.skip_check.outputs.continue == 'true'
steps:
- name: Checkout repo
uses: actions/checkout@v3
- name: Configure
id: cmake
run: |
mkdir $workingDir && cd $workingDir
cmd="cmake .."
case "${RUNNER_OS}" in
Linux) $cmd -DCMAKE_BUILD_TYPE=Release ;;
macOS) $cmd -DCMAKE_BUILD_TYPE=Release -DCMAKE_OSX_ARCHITECTURES="arm64;x86_64" ;;
Windows) $cmd -G "Visual Studio 17 2022" -A x64 -DCMAKE_CONFIGURATION_TYPES=Release ;;
*) echo "Do not recognise ${RUNNER_OS}." && exit 1 ;;
esac
- name: Build
working-directory: build
run: |
cmd="cmake --build ."
case "${RUNNER_OS}" in
Linux) $cmd ;;
macOS) $cmd ;;
Windows) $cmd --config Release ;;
*) echo "Do not recognise ${RUNNER_OS}." && exit 1 ;;
esac
- name: Test
working-directory: build
run: ctest
- uses: actions/upload-artifact@v3
name: Artifact
with:
name: ${{ needs.metadata.outputs.project }}-${{ runner.os }}
path: ${{ env.workingDir }}/${{ matrix.result }}
if-no-files-found: error
- name: list
run: |
ls -laR
Binary file added docs/SL.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 178fc01

Please sign in to comment.