diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 2fae65a3..74e12ba6 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -1,43 +1,35 @@ +# Usage: +# +# Build: +# uses: "./.github/workflows/build" +# with: +# build_type: Debug +# +# + name: Build on: - push: - branches: [dev, main] - paths-ignore: - - "docs/**" - - "*.md" - - "NewHorizons/Schemas/**" - - "LICENSE" - - ".gitignore" - pull_request: - paths-ignore: - - "docs/**" - - "*.md" - - "NewHorizons/Schemas/**" - - "LICENSE" - - ".gitignore" - workflow_dispatch: - -env: - GH_ACTIONS: 'true' + workflow_call: + inputs: + build_type: + description: 'Build type to pass to `dotnet`, should be either "Debug" or "Release"' + required: false + default: "Debug" + type: string + secrets: inherit + jobs: - build: + Build: runs-on: windows-latest steps: - - 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 + - name: Checkout Repo + uses: actions/checkout@v2 - - 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 - name: Disable strong name validation @@ -47,45 +39,23 @@ jobs: run: "rm .\\NewHorizons\\NewHorizons.csproj.user" - name: Build Project - run: dotnet build -c $Env:BUILD_TYPE + run: dotnet build -c ${{ inputs.build_type }} - name: Generate Schemas - run: .\SchemaExporter\bin\${{ env.BUILD_TYPE }}\SchemaExporter.exe + run: .\SchemaExporter\bin\${{ inputs.build_type }}\SchemaExporter.exe - 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 uses: actions/upload-artifact@v2 with: - name: xen.NewHorizons.${{ env.BUILD_TYPE }} - path: .\NewHorizons\bin\${{ env.BUILD_TYPE }} + name: xen.NewHorizons.${{ inputs.build_type }} + path: .\NewHorizons\bin\${{ inputs.build_type }} - name: Upload Schemas Artifact uses: actions/upload-artifact@v2 with: - name: NewHorizons-Schemas-${{ env.BUILD_TYPE }} + name: NewHorizons-Schemas-${{ inputs.build_type }} 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 }} - diff --git a/.github/workflows/debug_build.yml b/.github/workflows/debug_build.yml new file mode 100644 index 00000000..2e163d5d --- /dev/null +++ b/.github/workflows/debug_build.yml @@ -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 \ No newline at end of file diff --git a/.github/workflows/release_build.yml b/.github/workflows/release_build.yml new file mode 100644 index 00000000..5f51b703 --- /dev/null +++ b/.github/workflows/release_build.yml @@ -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 + + diff --git a/.github/workflows/update_release.yml b/.github/workflows/update_release.yml new file mode 100644 index 00000000..1730a09d --- /dev/null +++ b/.github/workflows/update_release.yml @@ -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 \ No newline at end of file diff --git a/.github/workflows/update_schemas.yml b/.github/workflows/update_schemas.yml new file mode 100644 index 00000000..65ddffeb --- /dev/null +++ b/.github/workflows/update_schemas.yml @@ -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 }} diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 00000000..9e4af289 --- /dev/null +++ b/.vscode/settings.json @@ -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" + } +} \ No newline at end of file