Skip to content

Commit 01142fe

Browse files
committed
Update CI and release actions to include some fixes from main MonoMod CI
1 parent 801e84c commit 01142fe

File tree

3 files changed

+63
-14
lines changed

3 files changed

+63
-14
lines changed

.github/workflows/ci.yml

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@ jobs:
2121
name: Setup
2222
runs-on: ubuntu-latest
2323
outputs:
24-
should_skip: ${{ steps.skip_check.outputs.should_skip }}
24+
should_skip: ${{ steps.skip_check.outputs.should_skip == 'true' || steps.msg_check.outputs.skip == 'true' }}
25+
upload_pkgs: ${{ steps.msg_check.outputs.skip != 'true' }}
2526
skipped_by: ${{ steps.skip_check.outputs.skipped_by }}
2627
ver: ${{ steps.computever.outputs.ver }}
2728
checkid: ${{ steps.result_check.outpus.check_id }}
@@ -32,7 +33,11 @@ jobs:
3233
with:
3334
cancel_others: true
3435
concurrent_skipping: same_content_newer
35-
36+
37+
- name: Check if this run is skipped by commit message
38+
id: msg_check
39+
run: echo "skip=${{ github.event_name == 'push' && contains(github.event.head_commit.message, '[skip-ci]') }}" >> $env:GITHUB_OUTPUT
40+
3641
- name: Compute Version
3742
id: computever
3843
run: echo "ver=$(Get-Date -Format y.M.d).${{ github.run_number }}.${{ github.run_attempt }}" >> $env:GITHUB_OUTPUT
@@ -47,8 +52,8 @@ jobs:
4752

4853
upload:
4954
needs: [setup, build]
50-
if: github.ref_name == 'master'
55+
if: ${{ needs.setup.outputs.upload_pkgs == 'true' && github.ref_name == 'master' && (success() || needs.setup.result == 'success') }}
5156
name: Upload Packages
5257
uses: ./.github/workflows/upload-packages.yml
5358
with:
54-
workflow-id: ${{ needs.setup.outputs.should_skip == 'true' && fromJSON(needs.setup.outputs.skipped_by).workflowId || github.run_id }}
59+
run-id: ${{ needs.setup.outputs.should_skip == 'true' && fromJSON(needs.setup.outputs.skipped_by).id || github.run_id }}

.github/workflows/release.yml

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -86,24 +86,37 @@ jobs:
8686

8787
bump-ver:
8888
name: Bump versions
89-
needs: [setup, build]
89+
needs: [setup, upload-github, upload-nuget]
90+
if: ${{ !failure() && !cancelled() }}
9091
runs-on: ubuntu-latest
9192

9293
permissions:
9394
contents: write
9495

9596
steps:
97+
- name: Authenticate as app
98+
uses: actions/create-github-app-token@v2
99+
id: app_tok
100+
with:
101+
app-id: ${{ vars.APP_ID }}
102+
private-key: ${{ secrets.APP_PRIVKEY }}
103+
96104
- name: Checkout
97105
uses: actions/checkout@v4
106+
with:
107+
token: ${{ steps.app_tok.outputs.token }} # checkout using the app token so we can push directly to the repo head
108+
lfs: true
109+
submodules: true
98110

99-
# first, make release/tag
100111
- name: Download compiled packages
101112
uses: actions/download-artifact@v4
102113
with:
103114
name: packages
104115
path: artifacts/package/release/
105116
github-token: ${{ github.token }}
106117
run-id: ${{ github.run_id }}
118+
119+
# first, make release/tag
107120
- name: Create release
108121
uses: softprops/action-gh-release@v2
109122
if: '!inputs.dryrun'
@@ -142,9 +155,11 @@ jobs:
142155
if: '!inputs.prerelease'
143156
uses: EndBug/add-and-commit@v9
144157
with:
145-
add: Version.props
146-
message: "[BOT]: Bump version after ${{ needs.setup.outputs.ver }}"
147-
committer_name: GitHub Actions
148-
committer_email: 41898282+github-actions[bot]@users.noreply.github.com
149-
push: ${{ !inputs.dryrun }}
158+
message: |
159+
[BOT]: Bump version after ${{ needs.setup.outputs.ver }} release
160+
161+
[skip-ci]
162+
default_author: github_actions
163+
push: ${{ !inputs.dryrun && 'origin --force --set-upstream' || 'false' }}
150164
pathspec_error_handling: exitAtEnd
165+

.github/workflows/upload-packages.yml

Lines changed: 32 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ name: Upload Packages
33
on:
44
workflow_call:
55
inputs:
6-
workflow-id:
6+
run-id:
77
type: string
88
default: ${{ github.run_id }}
99
description: The ID of the workflow to upload packages from
@@ -45,15 +45,44 @@ jobs:
4545
- name: Install .NET SDK
4646
uses: nike4613/install-dotnet@533307d1c90c37993c8ef1397388bc9783e7b87c
4747
with:
48-
global-json: global.json
48+
global-json: global.json
49+
50+
- name: Wait for packages to be available
51+
if: github.run_id != inputs.run-id
52+
shell: pwsh
53+
env:
54+
GH_TOKEN: ${{ github.token }}
55+
RUN_ID: ${{ inputs.run-id }}
56+
run: |
57+
while ($true)
58+
{
59+
$conclusion = gh api -H "Accept: application/vnd.github+json" -H "X-GitHub-Api-Version: 2022-11-28" `
60+
"/repos/${{ github.repository }}/actions/runs/$($env:RUN_ID)" `
61+
| ConvertFrom-Json `
62+
| % { $_.conclusion }
63+
if ($null -ne $conclusion)
64+
{
65+
if ($conclusion -ne "success")
66+
{
67+
echo "Build had conclusion '$conclusion'. Failing.";
68+
exit 1;
69+
}
70+
else
71+
{
72+
echo "Build succeeded. Continuing."
73+
exit 0;
74+
}
75+
}
76+
Start-Sleep -Seconds 30;
77+
}
4978
5079
- name: Download compiled packages
5180
uses: actions/download-artifact@v4
5281
with:
5382
name: packages
5483
path: artifacts/package/release/
5584
github-token: ${{ github.token }}
56-
run-id: ${{ inputs.workflow-id }}
85+
run-id: ${{ inputs.run-id }}
5786

5887
- name: Push packages
5988
run: dotnet nuget push -s "${{ inputs.nuget-url }}" -k ${{ secrets.nuget-key || github.token }} (Get-Item artifacts/package/release/*.nupkg)

0 commit comments

Comments
 (0)