-
Notifications
You must be signed in to change notification settings - Fork 39
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add workflows to push nuget packages, and update existing workflows
- Loading branch information
1 parent
993d026
commit 76738d2
Showing
15 changed files
with
484 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
name: 'NuGet Pack' | ||
description: 'Packs BitMono NuGet packages' | ||
inputs: | ||
nuspec_path: | ||
description: 'Path to .nuspec' | ||
required: true | ||
nuget_push: | ||
description: 'Push to Nuget?' | ||
required: false | ||
default: false | ||
nuget_key: | ||
description: 'NuGet deploy key' | ||
required: false | ||
runs: | ||
using: "composite" | ||
steps: | ||
- name: Pack | ||
run: nuget pack ${{ inputs.nuspec_path }} | ||
shell: bash | ||
- name: Push to NuGet (Release) | ||
run: if ${{ inputs.nuget_push == 'true' }}; then | ||
dotnet nuget push *.nupkg --skip-duplicate --api-key ${{ inputs.nuget_key }} --source https://api.nuget.org/v3/index.json; | ||
fi | ||
shell: bash |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
name: 'Project Build' | ||
description: 'Builds BitMono projects' | ||
inputs: | ||
project_path: | ||
description: 'Path to project folder' | ||
required: true | ||
create_artifacts: | ||
description: 'Creates artifacts' | ||
required: false | ||
target_framework: | ||
description: 'The target framework to build on' | ||
required: true | ||
github_token: | ||
description: 'GitHub token' | ||
required: false | ||
runtime_version: | ||
description: 'Build runtime version default linux-x64' | ||
required: false | ||
default: 'linux-x64' | ||
outputs: | ||
version: | ||
description: "Generated version (SemVersion compatible)" | ||
value: ${{ steps.get-version.outputs.version }} | ||
is_prerelease: | ||
description: 'Gets if the version is a prerelease' | ||
value: ${{ steps.check-prerelease.outputs.is_prerelease }} | ||
runs: | ||
using: "composite" | ||
steps: | ||
# Generate semver compatible version from current tag and commit hash | ||
- name: Create version | ||
id: get-version | ||
run: echo "version=$(git describe --tags `git rev-list --tags --max-count=1`)+$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT | ||
shell: bash | ||
|
||
- name: Check Prerelease | ||
id: check-prerelease | ||
run: "if ${{ contains(steps.get-version.outputs.version, '-') }}; then | ||
echo is_prerelease=true >> $GITHUB_OUTPUT; | ||
else | ||
echo is_prerelease=false >> $GITHUB_OUTPUT; | ||
fi" | ||
shell: bash | ||
|
||
# Set execute permissions for all relevant files and directories | ||
- name: Set execute permissions | ||
run: chmod -R +x $GITHUB_WORKSPACE/ | ||
shell: bash | ||
|
||
# Commands that are used multiple times. | ||
# Placed in one place to make sure that the arguments would always be the same | ||
- name: Common commands | ||
id: common-commands | ||
run: | | ||
echo "dotnet-restore=dotnet restore \$PROJECT_PATH --runtime ${{ inputs.runtime_version }}" -p:Configuration=Release -p:TargetFramework=${{ inputs.target_framework }} -p:CreateBitMonoArtifacts=${{ inputs.create_artifacts }} >> $GITHUB_OUTPUT | ||
echo "dotnet-build=dotnet build \$PROJECT_PATH --configuration Release --no-restore -p:TargetFramework=${{ inputs.target_framework }} -p:BitMonoVersion=${{ steps.get-version.outputs.version }} --runtime ${{ inputs.runtime_version }}" >> $GITHUB_OUTPUT | ||
echo "dotnet-test=dotnet test \$PROJECT_PATH --configuration Release --no-restore --no-build -p:TargetFramework=${{ inputs.target_framework }} --runtime ${{ inputs.runtime_version }}" >> $GITHUB_OUTPUT | ||
shell: bash | ||
|
||
# Install dependencies (this needs to be a separate step from build for caching) | ||
- name: Install dependencies | ||
run: | | ||
${{ steps.common-commands.outputs.dotnet-restore }} | ||
pwsh -File .github/actions/project-build/run-command-for-every-tests-project.ps1 "$GITHUB_WORKSPACE/tests" '${{ steps.common-commands.outputs.dotnet-restore }}' | ||
env: | ||
PROJECT_PATH: ${{ inputs.project_path }} # Used by commands in `common-commands` step | ||
shell: bash | ||
|
||
# Build project | ||
- name: Build | ||
run: | | ||
${{ steps.common-commands.outputs.dotnet-build }} | ||
pwsh -File .github/actions/project-build/run-command-for-every-tests-project.ps1 "$GITHUB_WORKSPACE/tests" '${{ steps.common-commands.outputs.dotnet-build }}' | ||
env: | ||
PROJECT_PATH: ${{ inputs.project_path }} # Used by commands in `common-commands` step | ||
shell: bash | ||
|
||
# Test project | ||
- name: Test | ||
run: | | ||
pwsh -File .github/actions/project-build/run-command-for-every-tests-project.ps1 "$GITHUB_WORKSPACE/tests" '${{ steps.common-commands.outputs.dotnet-test }}' | ||
env: | ||
PROJECT_PATH: ${{ inputs.project_path }} # Used by commands in `common-commands` step | ||
shell: bash |
31 changes: 31 additions & 0 deletions
31
.github/actions/project-build/run-command-for-every-tests-project.ps1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
# | ||
# Finds all tests projects matching 'BitMono.*.Tests' for a project passed as the first argument | ||
# and runs a command passed as the second argument for every tests project found. | ||
# Also sets PROJECT_PATH environment variables with the value of the tests project folder path. | ||
# Exits with a non-zero status if any command fails. | ||
# | ||
# Example usage: | ||
# pwsh -f .github/actions/project-build/run-command-for-every-tests-project.ps1 "src/BitMono.Core" "echo \$PROJECT_PATH" | ||
# | ||
# Example output: | ||
# Tests project found: /home/runner/work/BitMono/BitMono/tests/BitMono.Core.Tests. Executing a command: ... | ||
# Assumes the first argument is already the path to the tests directory. | ||
|
||
$testsFolderPath = $args[0] | ||
$commandToExecute = $args[1] | ||
$global:exitCode = 0 | ||
|
||
Get-ChildItem -Path $testsFolderPath -Directory -Recurse ` | ||
| Where-Object { $_.Name -match "^BitMono\..*\.Tests$" } ` | ||
| ForEach-Object { | ||
$testsProjectPath = $_.FullName | ||
Write-Output "Tests project found: $testsProjectPath. Executing a command: $commandToExecute" | ||
bash -c "PROJECT_PATH=$testsProjectPath && $commandToExecute" | ||
if ($LASTEXITCODE -ne 0) { | ||
$global:exitCode = $LASTEXITCODE | ||
} | ||
} | ||
|
||
if ($global:exitCode -ne 0) { | ||
exit $global:exitCode | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
name: BitMono.API | ||
|
||
on: | ||
create: | ||
tags: | ||
- "*" | ||
push: | ||
branches: [ master ] | ||
paths: | ||
- '.github/workflows/BitMono.API.yaml' | ||
- 'src/BitMono.API/**' | ||
pull_request: | ||
branches: [ master ] | ||
paths: | ||
- '.github/workflows/BitMono.API.yaml' | ||
- 'src/BitMono.API/**' | ||
|
||
jobs: | ||
build: | ||
name: "BitMono.API Build" | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 | ||
|
||
- uses: actions/setup-dotnet@v4 | ||
name: Setup .NET | ||
with: | ||
dotnet-version: 8.x | ||
|
||
- uses: ./.github/actions/project-build | ||
id: project-build | ||
with: | ||
project_path: src/BitMono.API | ||
github_token: ${{ secrets.PAT }} | ||
nuget_key: ${{ secrets.NUGET_DEPLOY_KEY }} | ||
nuget_push: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
name: BitMono.Core | ||
|
||
on: | ||
create: | ||
tags: | ||
- "*" | ||
push: | ||
branches: [ master ] | ||
paths: | ||
- '.github/workflows/BitMono.Core.yaml' | ||
- 'src/BitMono.Core/**' | ||
pull_request: | ||
branches: [ master ] | ||
paths: | ||
- '.github/workflows/BitMono.Core.yaml' | ||
- 'src/BitMono.Core/**' | ||
|
||
jobs: | ||
build: | ||
name: "BitMono.Core Build" | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 | ||
|
||
- uses: actions/setup-dotnet@v4 | ||
name: Setup .NET | ||
with: | ||
dotnet-version: 8.x | ||
|
||
- uses: ./.github/actions/project-build | ||
id: project-build | ||
with: | ||
project_path: src/BitMono.Core | ||
github_token: ${{ secrets.PAT }} | ||
nuget_key: ${{ secrets.NUGET_DEPLOY_KEY }} | ||
nuget_push: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
name: BitMono.Host | ||
|
||
on: | ||
create: | ||
tags: | ||
- "*" | ||
push: | ||
branches: [ master ] | ||
paths: | ||
- '.github/workflows/BitMono.Host.yaml' | ||
- 'src/BitMono.Host/**' | ||
pull_request: | ||
branches: [ master ] | ||
paths: | ||
- '.github/workflows/BitMono.Host.yaml' | ||
- 'src/BitMono.Host/**' | ||
|
||
jobs: | ||
build: | ||
name: "BitMono.Host Build" | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 | ||
|
||
- uses: actions/setup-dotnet@v4 | ||
name: Setup .NET | ||
with: | ||
dotnet-version: 8.x | ||
|
||
- uses: ./.github/actions/project-build | ||
id: project-build | ||
with: | ||
project_path: src/BitMono.Host | ||
github_token: ${{ secrets.PAT }} | ||
nuget_key: ${{ secrets.NUGET_DEPLOY_KEY }} | ||
nuget_push: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
name: BitMono.Obfuscation | ||
|
||
on: | ||
create: | ||
tags: | ||
- "*" | ||
push: | ||
branches: [ master ] | ||
paths: | ||
- '.github/workflows/BitMono.Obfuscation.yaml' | ||
- 'src/BitMono.Obfuscation/**' | ||
pull_request: | ||
branches: [ master ] | ||
paths: | ||
- '.github/workflows/BitMono.Obfuscation.yaml' | ||
- 'src/BitMono.Obfuscation/**' | ||
|
||
jobs: | ||
build: | ||
name: "BitMono.Obfuscation Build" | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 | ||
|
||
- uses: actions/setup-dotnet@v4 | ||
name: Setup .NET | ||
with: | ||
dotnet-version: 8.x | ||
|
||
- uses: ./.github/actions/project-build | ||
id: project-build | ||
with: | ||
project_path: src/BitMono.Obfuscation | ||
github_token: ${{ secrets.PAT }} | ||
nuget_key: ${{ secrets.NUGET_DEPLOY_KEY }} | ||
nuget_push: true |
Oops, something went wrong.