Skip to content

Commit 0bb085a

Browse files
committed
Update workflows
1 parent ffa0f9f commit 0bb085a

File tree

7 files changed

+214
-61
lines changed

7 files changed

+214
-61
lines changed

.github/actions/build/action.yml

Lines changed: 33 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,45 @@
1-
name: 'Build'
1+
name: "Build"
2+
23
inputs:
34
sln-path:
4-
description: 'Path to the solution file relative to the root of the project'
5+
description: "Path to the solution file relative to the root of the project"
56
required: false
6-
default: '.'
7+
default: "."
78
build-config:
8-
description: 'Configuration to build'
9+
description: "Configuration to build"
910
required: true
11+
artifact-name:
12+
description: "Artifact file name"
13+
required: false
14+
default: compiled-dll-${{ github.sha }}
15+
1016
runs:
1117
using: "composite"
1218
steps:
13-
- name: Add MSBuild to PATH
14-
uses: microsoft/setup-msbuild@v1
19+
- name: Add MSBuild to PATH
20+
uses: microsoft/setup-msbuild@v1
1521

16-
- name: Restore NuGet packages
17-
working-directory: ${{env.GITHUB_WORKSPACE}}
18-
run: nuget restore ${{inputs.sln-path}}
19-
shell: cmd
22+
- name: Restore NuGet packages
23+
working-directory: ${{ env.GITHUB_WORKSPACE }}
24+
run: nuget restore ${{ inputs.sln-path }}
25+
shell: cmd
2026

21-
- uses: ammaraskar/msvc-problem-matcher@master
27+
- uses: ammaraskar/msvc-problem-matcher@master
2228

23-
- name: Build
24-
working-directory: ${{env.GITHUB_WORKSPACE}}
25-
# Add additional options to the MSBuild command line here (like platform or verbosity level).
26-
# See https://docs.microsoft.com/visualstudio/msbuild/msbuild-command-line-reference
27-
run: msbuild /m /p:Configuration=${{inputs.build-config}} /p:GitCommit=${{github.sha}} /p:GitBranch=${{github.ref}} ${{inputs.sln-path}}
28-
shell: cmd
29+
- name: Build
30+
working-directory: ${{ env.GITHUB_WORKSPACE }}
31+
# Add additional options to the MSBuild command line here (like platform or verbosity level).
32+
# See https://docs.microsoft.com/visualstudio/msbuild/msbuild-command-line-reference
33+
run: msbuild /m /p:Configuration=${{inputs.build-config}} /p:GitCommit=${{github.sha}} /p:GitBranch=${{github.ref}} ${{inputs.sln-path}}
34+
shell: cmd
2935

30-
- name: Upload Artifact
31-
if: ${{success()}}
32-
uses: actions/upload-artifact@v2
33-
with:
34-
name: compiled-dll-${{github.sha}}
35-
path: |
36-
${{inputs.sln-path}}/${{inputs.build-config}}/cncnet5.dll
37-
${{inputs.sln-path}}/${{inputs.build-config}}/cncnet5.pdb
36+
- name: Upload Artifact
37+
if: ${{ success() }}
38+
uses: actions/upload-artifact@v4
39+
with:
40+
name: ${{ inputs.artifact-name }}
41+
path: |
42+
${{inputs.sln-path}}/${{inputs.build-config}}/cncnet5.dll
43+
${{inputs.sln-path}}/${{inputs.build-config}}/cncnet5.pdb
44+
./LICENSE.md
45+
./README.md

.github/workflows/editorconfig.yml renamed to .github/workflows/editorconfig-checker.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: EditorConfig
1+
name: "Editor Config Checker"
22

33
on:
44
pull_request:
@@ -12,6 +12,6 @@ jobs:
1212
lint:
1313
runs-on: windows-2019
1414
steps:
15-
- uses: actions/checkout@v3
15+
- uses: actions/checkout@v4
1616
- name: editorconfig-checker
1717
run: scripts/editorconfig-checker.bat

.github/workflows/nightly-build.yml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
name: "Nightly Build"
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
- develop
8+
9+
env:
10+
SOLUTION_PATH: .
11+
BUILD_CONFIGURATION: DevBuild
12+
13+
jobs:
14+
build:
15+
runs-on: windows-2019
16+
17+
steps:
18+
- uses: actions/checkout@v4
19+
with:
20+
submodules: recursive
21+
22+
- name: Build
23+
uses: ./.github/actions/build
24+
with:
25+
sln-path: ${{ env.SOLUTION_PATH }}
26+
build-config: ${{ env.BUILD_CONFIGURATION }}

.github/workflows/nightly.yml

Lines changed: 0 additions & 34 deletions
This file was deleted.
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
name: "Pull Request Nightly Build"
2+
3+
on:
4+
pull_request:
5+
6+
env:
7+
SOLUTION_PATH: .
8+
BUILD_CONFIGURATION: DevBuild
9+
10+
jobs:
11+
build:
12+
runs-on: windows-2019
13+
14+
steps:
15+
- uses: actions/checkout@v4
16+
with:
17+
submodules: recursive
18+
19+
- name: Build
20+
uses: ./.github/actions/build
21+
with:
22+
sln-path: ${{ env.SOLUTION_PATH }}
23+
build-config: ${{ env.BUILD_CONFIGURATION }}
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
name: "Nightly Build Comment on Pull Request"
2+
on:
3+
workflow_run:
4+
workflows: ['Pull Request Nightly Build']
5+
types: [completed]
6+
jobs:
7+
pr_comment:
8+
if: github.event.workflow_run.event == 'pull_request' && github.event.workflow_run.conclusion == 'success'
9+
runs-on: ubuntu-latest
10+
steps:
11+
- name: Get the PR number
12+
run: |
13+
# Query the issue search API to get the PR associated with it
14+
PR_RAW=$(curl 'https://api.github.com/search/issues?q=${{ github.event.workflow_run.head_commit.id }}')
15+
# Get the event number from the search results, which will
16+
# be the PR number
17+
# Filter by PRs only in this repository, as a PR with an identical head commit may be made in another repository (e.g. a fork)
18+
# Assume the 0th index in the array of found PRs is the correct one (it seems to usually be the latest one)
19+
PR_NUM=$(echo $PR_RAW | jq '.items | map(select(.repository_url=="https://api.github.com/repos/${{ github.repository }}")) | .[0].number')
20+
echo "PR_NUM=${PR_NUM}" >> ${GITHUB_ENV}
21+
22+
- name: Comment on PR
23+
uses: actions/github-script@v7
24+
with:
25+
# This snippet is public-domain, taken from
26+
# https://github.com/oprypin/nightly.link/blob/master/.github/workflows/pr-comment.yml
27+
# and modified to allow comments on external PRs
28+
script: |
29+
async function upsertComment(owner, repo, issue_number, purpose, body) {
30+
const {data: comments} = await github.rest.issues.listComments(
31+
{owner, repo, issue_number});
32+
33+
const marker = `<!-- bot: ${purpose} -->`;
34+
body = marker + "\n" + body;
35+
36+
const existing = comments.filter((c) => c.body.includes(marker));
37+
if (existing.length > 0) {
38+
const last = existing[existing.length - 1];
39+
core.info(`Updating comment ${last.id}`);
40+
await github.rest.issues.updateComment({
41+
owner, repo,
42+
body,
43+
comment_id: last.id,
44+
});
45+
} else {
46+
core.info(`Creating a comment in issue / PR #${issue_number}`);
47+
await github.rest.issues.createComment({issue_number, body, owner, repo});
48+
}
49+
}
50+
51+
const {owner, repo} = context.repo;
52+
const run_id = ${{github.event.workflow_run.id}};
53+
54+
const artifacts = await github.paginate(
55+
github.rest.actions.listWorkflowRunArtifacts, {owner, repo, run_id});
56+
if (!artifacts.length) {
57+
return core.error(`No artifacts found`);
58+
}
59+
let body = `Nightly build for this pull request:\n`;
60+
for (const art of artifacts) {
61+
body += `\n* [${art.name}.zip](https://nightly.link/${owner}/${repo}/actions/artifacts/${art.id}.zip)`;
62+
}
63+
64+
body += `\nThese artifacts will expire in 90 days and will not be available for download after that time.`;
65+
body += `\n\n_This comment is automatic and is meant to allow guests to get latest nightly builds for this pull request without registering. It is updated on every successful build._`;
66+
67+
core.info("Review thread message body:", body);
68+
await upsertComment(owner, repo, ${{ env.PR_NUM }}, "nightly-link", body);

.github/workflows/release-build.yml

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
name: "Release Build"
2+
3+
on:
4+
push:
5+
tags:
6+
- "v*.*.*.*"
7+
8+
env:
9+
RELEASE_NAME: ${{ github.ref_name }}
10+
ARTIFACT_NAME: cncnet5_${{ github.ref_name }}.zip
11+
12+
SOLUTION_PATH: .
13+
BUILD_CONFIGURATION: Release
14+
15+
jobs:
16+
build:
17+
runs-on: windows-2019
18+
19+
steps:
20+
- uses: actions/checkout@v4
21+
with:
22+
submodules: recursive
23+
24+
- name: Build
25+
uses: ./.github/actions/build
26+
with:
27+
sln-path: ${{ env.SOLUTION_PATH }}
28+
build-config: ${{ env.BUILD_CONFIGURATION }}
29+
30+
- name: Create Archive For Release
31+
run: |
32+
mkdir ./artifact
33+
copy ./LICENSE.md ./artifact/LICENSE.md
34+
copy ./README.md ./artifact/README.md
35+
copy ./${{ env.BUILD_CONFIGURATION }}/cncnet5.pdb ./artifact/cncnet5.pdb
36+
copy ./${{ env.BUILD_CONFIGURATION }}/cncnet5.dll ./artifact/cncnet5.dll
37+
7z a ${{ env.ARTIFACT_NAME }} ./artifact/*
38+
39+
- name: Upload New Release
40+
uses: softprops/action-gh-release@v2
41+
with:
42+
name: ${{ env.RELEASE_NAME }}
43+
tag_name: ${{ env.RELEASE_NAME }}
44+
body: ${{ env.RELEASE_NAME }}
45+
append_body: true
46+
draft: true
47+
files: |
48+
${{ env.ARTIFACT_NAME }}
49+
50+
request-anti-cheat-build:
51+
needs: [build]
52+
runs-on: ubuntu-latest
53+
steps:
54+
- name: Request AntiCheat Build
55+
run: |
56+
curl -L \
57+
-X POST \
58+
-H "Accept: application/vnd.github+json" \
59+
-H "Authorization: Bearer ${{ secrets.ACCESS_TOKEN }}" \
60+
-H "X-GitHub-Api-Version: 2022-11-28" \
61+
https://api.github.com/repos/cncnet/yrpp-spawner-private/actions/workflows/release-build-by-request.yml/dispatches \
62+
-d '{"ref":"main", "inputs":{"tag": "${{ github.ref_name }}"}}'

0 commit comments

Comments
 (0)