-
Notifications
You must be signed in to change notification settings - Fork 0
102 lines (90 loc) · 4.43 KB
/
dotnet-version.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
--- # Create a new branch for the latest (released) dotnet version if there's an update
name: "Repo: Update Dotnet Version to latest released version"
on:
push:
branches:
- "main"
paths:
- ".github/workflows/dotnet-version.yml"
schedule:
- cron: "0 1 * * *"
concurrency:
group: ${{github.workflow}}-${{github.ref}}
cancel-in-progress: false
permissions:
contents: write
jobs:
bump-dotnet-sdk-version:
if: endsWith(github.repository, 'funfair-server-template')
runs-on: [self-hosted, linux]
steps:
- name: "Initialise Workspace"
shell: bash
run: sudo chown -R "$USER:$USER" "$GITHUB_WORKSPACE"
- name: "Checkout Source"
uses: actions/[email protected]
with:
fetch-depth: 0
fetch-tags: true
token: ${{secrets.SOURCE_PUSH_TOKEN}}
- name: "Install Build tools"
uses: ./.github/actions/build-tools
with:
GITHUB_TOKEN: ${{secrets.SOURCE_PUSH_TOKEN}}
NUGET_PUBLIC_RESTORE_FEED_CACHE: ${{steps.nuget-local-cache.outputs.NUGET_BAGET_CACHE}}
NUGET_PUBLIC_RESTORE_FEED: ${{vars.NUGET_PUBLIC_RESTORE_FEED}}
NUGET_ADDITIONAL_RESTORE_FEED_RELEASE_CACHE: ${{steps.nuget-local-cache.outputs.RELEASE_BAGET_CACHE}}
NUGET_ADDITIONAL_RESTORE_FEED_PRERELEASE_CACHE: ${{steps.nuget-local-cache.outputs.PRERELEASE_BAGET_CACHE}}
NUGET_ADDITIONAL_RESTORE_FEED_RELEASE: ${{vars.NUGET_ADDITIONAL_RESTORE_FEED_RELEASE}}
NUGET_ADDITIONAL_RESTORE_FEED_PRERELEASE: ${{vars.NUGET_ADDITIONAL_RESTORE_FEED_PRERELEASE}}
- name: "Get latest installed dotnet version"
id: latest-dotnet-version
run: |
echo "LATEST_RELEASE_VERSION=$(dotnet --list-sdks | cut -f 1 -d " " | grep "^[0-9]*\.[0-9]*\.[0-9]*$" | sort | tail -1)" >> "$GITHUB_OUTPUT"
- name: "Display latest installed dotnet version"
run: |
echo "Latest installed dotnet version: ${{steps.latest-dotnet-version.outputs.LATEST_RELEASE_VERSION}}"
echo "Requested dotnet version: ${{env.DOTNET_VERSION}}"
- name: "Switch to version branch"
if: ${{env.DOTNET_VERSION}} < ${{steps.latest-dotnet-version.outputs.LATEST_RELEASE_VERSION}}
shell: bash
run: |
git checkout "depends/dotnet/${{env.NEW_DOTNET_VERSION}}" || git checkout -b "depends/dotnet/${{env.NEW_DOTNET_VERSION}}"
env:
NEW_DOTNET_VERSION: ${{steps.latest-dotnet-version.outputs.LATEST_RELEASE_VERSION}}
- name: "Update global.json to latest version"
if: ${{env.DOTNET_VERSION}} < ${{steps.latest-dotnet-version.outputs.LATEST_RELEASE_VERSION}}
shell: bash
working-directory: src
run: |
echo "Should update to ${{steps.latest-dotnet-version.outputs.LATEST_RELEASE_VERSION}}"
mv "global.json" "global.json.tmp";
jq --arg v "$NEW_DOTNET_VERSION" '.sdk.version = $v' < "global.json.tmp" > "global.json";
[ -f "global.json.tmp" ] && rm -f "global.json.tmp"
cat "global.json"
env:
NEW_DOTNET_VERSION: ${{steps.latest-dotnet-version.outputs.LATEST_RELEASE_VERSION}}
- name: "Push"
if: ${{env.DOTNET_VERSION}} < ${{steps.latest-dotnet-version.outputs.LATEST_RELEASE_VERSION}}
shell: bash
working-directory: src
run: |
git config --global user.name 'fun-version[bot]'
git config --global user.email '[email protected]'
git diff
git add "global.json"
git commit -m "SDK - Update DotNet SDK to $NEW_DOTNET_VERSION"
git push --set-upstream origin "depends/dotnet/$NEW_DOTNET_VERSION"
env:
NEW_DOTNET_VERSION: ${{steps.latest-dotnet-version.outputs.LATEST_RELEASE_VERSION}}
# - name: "Commit changes to new branch"
# if: ${{env.DOTNET_VERSION}} < ${{steps.latest-dotnet-version.outputs.LATEST_RELEASE_VERSION}}
# uses: stefanzweifel/[email protected]
# with:
# commit_message: "SDK - Update DotNet SDK to ${{steps.latest-dotnet-version.outputs.LATEST_RELEASE_VERSION}}"
# branch: "depends/dotnet/${{steps.latest-dotnet-version.outputs.LATEST_RELEASE_VERSION}}"
# file_pattern: src/global.json
# commit_user_name: "fun-version[bot]"
# commit_user_email: "[email protected]"
# commit_author: "fun-version[bot] <[email protected]>"
# skip_dirty_check: false