Add New Actions

This commit is contained in:
Ben C 2022-07-11 13:54:23 -04:00 committed by GitHub
parent 26e543d639
commit 41376ac6bb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 195 additions and 59 deletions

View File

@ -1,43 +1,35 @@
# Usage:
#
# Build:
# uses: "./.github/workflows/build"
# with:
# build_type: Debug
#
#
name: Build name: Build
on: on:
push: workflow_call:
branches: [dev, main] inputs:
paths-ignore: build_type:
- "docs/**" description: 'Build type to pass to `dotnet`, should be either "Debug" or "Release"'
- "*.md" required: false
- "NewHorizons/Schemas/**" default: "Debug"
- "LICENSE" type: string
- ".gitignore" secrets: inherit
pull_request:
paths-ignore:
- "docs/**"
- "*.md"
- "NewHorizons/Schemas/**"
- "LICENSE"
- ".gitignore"
workflow_dispatch:
env:
GH_ACTIONS: 'true'
jobs: jobs:
build: Build:
runs-on: windows-latest runs-on: windows-latest
steps: steps:
- uses: actions/checkout@v2 - name: Checkout Repo
uses: actions/checkout@v2
# Set to Release if we're in master, otherwise keep us in Debug
- name: Set Release
if: github.ref == 'refs/heads/main'
run: echo "BUILD_TYPE=Release" | Out-File -FilePath $Env:GITHUB_ENV -Encoding utf-8 -Append
- name: Set Debug
if: github.ref != 'refs/heads/main'
run: echo "BUILD_TYPE=Debug" | Out-File -FilePath $Env:GITHUB_ENV -Encoding utf-8 -Append
- uses: actions/setup-dotnet@v1 - name: Setup .NET
uses: actions/setup-dotnet@v1
# Disable Strong Name Verification to let us pull a switch-a-roo # Disable Strong Name Verification to let us pull a switch-a-roo
- name: Disable strong name validation - name: Disable strong name validation
@ -47,45 +39,23 @@ jobs:
run: "rm .\\NewHorizons\\NewHorizons.csproj.user" run: "rm .\\NewHorizons\\NewHorizons.csproj.user"
- name: Build Project - name: Build Project
run: dotnet build -c $Env:BUILD_TYPE run: dotnet build -c ${{ inputs.build_type }}
- name: Generate Schemas - name: Generate Schemas
run: .\SchemaExporter\bin\${{ env.BUILD_TYPE }}\SchemaExporter.exe run: .\SchemaExporter\bin\${{ inputs.build_type }}\SchemaExporter.exe
- name: Delete XML documentation - name: Delete XML documentation
run: rm .\NewHorizons\bin\${{ env.BUILD_TYPE }}\NewHorizons.xml run: rm .\NewHorizons\bin\${{ inputs.build_type }}\NewHorizons.xml
- name: Upload Mod Artifact - name: Upload Mod Artifact
uses: actions/upload-artifact@v2 uses: actions/upload-artifact@v2
with: with:
name: xen.NewHorizons.${{ env.BUILD_TYPE }} name: xen.NewHorizons.${{ inputs.build_type }}
path: .\NewHorizons\bin\${{ env.BUILD_TYPE }} path: .\NewHorizons\bin\${{ inputs.build_type }}
- name: Upload Schemas Artifact - name: Upload Schemas Artifact
uses: actions/upload-artifact@v2 uses: actions/upload-artifact@v2
with: with:
name: NewHorizons-Schemas-${{ env.BUILD_TYPE }} name: NewHorizons-Schemas-${{ inputs.build_type }}
path: .\NewHorizons\Schemas path: .\NewHorizons\Schemas
# Only want to commit schemas if they've actually changed
- name: Verify Changed Schemas
uses: tj-actions/verify-changed-files@v9.1
id: changed_files
with:
files: NewHorizons\Schemas\**
- name: Commit Schemas
if: steps.changed_files.outputs.files_changed == 'true'
run: |
git config --local user.email "github-actions[bot]@users.noreply.github.com"
git config --local user.name "github-actions[bot]"
git add NewHorizons\Schemas\**
git commit -m "Updated Schemas"
- name: Push Schemas
if: ${{ (steps.changed_files.outputs.files_changed == 'true') && (github.event_name != 'pull_request') }}
uses: ad-m/github-push-action@master
with:
github_token: ${{ secrets.github_token }}
branch: ${{ github.ref }}

24
.github/workflows/debug_build.yml vendored Normal file
View File

@ -0,0 +1,24 @@
name: Debug Build
on:
push:
branches-ignore: [main]
paths-ignore:
- "docs/**"
- "*.md"
- "NewHorizons/Schemas/**"
- "LICENSE"
- ".gitignore"
workflow_dispatch:
jobs:
Build:
uses: './.github/workflows/build.yaml'
with:
build_type: Debug
Update_Schemas:
name: 'Update Schemas'
needs: Build
uses: './.github/workflows/update_schemas.yml'
with:
artifact_name: NewHorizons-Schemas-Debug

63
.github/workflows/release_build.yml vendored Normal file
View File

@ -0,0 +1,63 @@
name: Release Build
on:
push:
branches: [main]
paths-ignore:
- "docs/**"
- "*.md"
- "NewHorizons/Schemas/**"
- "LICENSE"
- ".gitignore"
pull_request:
branches: [main]
types:
- synchronize
paths-ignore:
- "docs/**"
- "*.md"
- "NewHorizons/Schemas/**"
- "LICENSE"
- ".gitignore"
jobs:
Build:
uses: ./.github/workflows/build.yaml
with:
build_type: Release
Update_Schemas:
name: 'Update Schemas'
needs: Build
uses: ./.github/workflows/update_schemas.yml
with:
artifact_name: NewHorizons-Schemas-Release
Update_Release:
name: 'Create/Update Release Asset'
needs: Build
if: ${{ github.event.name == 'pull_request' && github.event.pull_request.draft == 'false' && contains(github.event.pull_request.labels.*.name, 'update-pr') }}
runs-on: ubuntu-latest
steps:
- name: Download Asset
uses: actions/download-artifact@v3
with:
name: xen.NewHorizons.Release
path: xen.NewHorizons
- name: Zip Asset
uses: montudor/action-zip@v1
with:
args: zip -qq -r xen.NewHorizons.zip xen.NewHorizons
- name: Upload Asset
uses: ncipollo/release-action@v1
with:
allowUpdates: true
commit: main
tag: v${{ github.event.pull_request.title }}
name: Version ${{ github.event.pull_request.title }}
omitBodyDuringUpdate: true
artifacts: "xen.NewHorizons.zip"
draft: true
prerelease: false

30
.github/workflows/update_release.yml vendored Normal file
View File

@ -0,0 +1,30 @@
name: Create/Update Release
on:
pull_request:
branches: [main]
types:
- ready_for_review
- edited
- labeled
jobs:
Update_Release:
name: Create/Update Release
if: ${{ github.event.type == 'PullRequest' && github.event.pull_request.draft == 'false' && contains(github.event.pull_request.labels.*.name, 'update-pr') }}
runs-on: ubuntu-latest
steps:
- name: Create/Update Draft Release
if: contains(github.event.pull_request.labels.*.name, 'version-pr')
uses: ncipollo/release-action@v1
with:
allowUpdates: true
name: Version ${{ github.event.pull_request.title }}
tag: v${{ github.event.pull_request.title }}
commit: main
body: |
${{ github.event.pull_request.body }}
**Generated From PR: ${{ github.event.pull_request.html_url }}**
draft: true
prerelease: false

44
.github/workflows/update_schemas.yml vendored Normal file
View File

@ -0,0 +1,44 @@
name: Update Schemas
on:
workflow_call:
inputs:
artifact_name:
required: true
description: 'Name of the artifact to download and check against'
type: string
secrets: inherit
jobs:
update_schemas:
runs-on: ubuntu-latest
steps:
- name: Checkout Repo
uses: actions/checkout@v2
- name: Download Artifact
uses: actions/download-artifact@v3
with:
name: ${{ inputs.artifact_name }}
path: NewHorizons/Schemas/
- name: Verify Changed Schemas
uses: tj-actions/verify-changed-files@v9.1
id: changed_files
with:
files: NewHorizons/Schemas/**
- name: Commit Schemas
if: steps.changed_files.outputs.files_changed == 'true'
run: |
git config --local user.email "github-actions[bot]@users.noreply.github.com"
git config --local user.name "github-actions[bot]"
git add NewHorizons\Schemas\**
git commit -m "Updated Schemas"
- name: Push Schemas
if: ${{ (steps.changed_files.outputs.files_changed == 'true') && (github.event_name != 'pull_request') }}
uses: ad-m/github-push-action@master
with:
github_token: ${{ secrets.github_token }}
branch: ${{ github.ref }}

5
.vscode/settings.json vendored Normal file
View File

@ -0,0 +1,5 @@
{
"yaml.schemas": {
"https://json.schemastore.org/github-workflow.json": "vscode-vfs://github%2B7b2276223a312c22726566223a7b2274797065223a342c226964223a226465766f70732f6e65772d776f726b666c6f7773227d7d/xen-42/outer-wilds-new-horizons/.github/workflows/build.yaml"
}
}