-
Notifications
You must be signed in to change notification settings - Fork 3
130 lines (110 loc) · 4.81 KB
/
build-dotnet.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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
name: "Generate .NET SDK"
on:
pull_request:
workflow_dispatch:
schedule:
# Run generation nightly on latest OpenAPI spec
- cron: '0 0 * * *'
jobs:
cloud-builds:
strategy:
matrix:
platform: [dotcom, ghec]
fail-fast: false
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
- uses: actions/setup-dotnet@v4
with:
dotnet-version: '8.x.x'
- uses: actions/setup-go@v3.5.0
with:
go-version: '1.21.5'
- name: Set repository name from platform for later use
run: |
if [ "${{ matrix.platform }}" == "dotcom" ]; then
echo "REPO_NAME=dotnet-sdk" >> $GITHUB_ENV
else
echo "REPO_NAME=dotnet-sdk-enterprise-cloud" >> $GITHUB_ENV
fi
- name: Run scripts/generate-dotnet.sh
run: scripts/generate-dotnet.sh ${{ matrix.platform }}
- name: Clean up build artifacts before syncing
run: dotnet clean stage/dotnet/$REPO_NAME/GitHub.Octokit.sln
- name: Clone the existing repository
run: |
cd ../
git clone https://github.com/octokit/$REPO_NAME.git
- name: Copy generated code to dotnet-sdk
run: |
cp -rf stage/dotnet/$REPO_NAME/. ../$REPO_NAME/ # copy everything
rsync -av --delete stage/dotnet/$REPO_NAME/src/ ../$REPO_NAME/src/ # delete files that are not generated
- uses: gr2m/create-or-update-pull-request-action@cd-path
if: github.event_name != 'pull_request' # do not update the SDK on PR builds
env:
GITHUB_TOKEN: ${{ secrets.OCTOKITBOT_SDK_PAT }}
REPO_NAME: ${{ env.REPO_NAME }}
with:
title: "Changes in generated code"
body: >
The latest OpenAPI spec resulted in changes to the generated code. Please review, set an applicable
commit message, merge, and tag a release as appropriate.
branch: "generated-code-update"
author: "Octokit Bot <security+octokitbot@github.com>"
commit-message: "New updates to generated code"
repository: "octokit/${{ env.REPO_NAME }}"
path-to-cd-to: "../${{ env.REPO_NAME }}"
server-builds:
strategy:
matrix:
version: ["3.11", "3.12", "3.13", "3.14"] # versions must be quoted or 3.10 becomes 3.1
fail-fast: false
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
- uses: actions/setup-dotnet@v4
with:
dotnet-version: '8.x.x'
- uses: actions/setup-go@v3.5.0
with:
go-version: '1.21.5'
- name: Run scripts/generate-dotnet.sh
run: scripts/generate-dotnet.sh ghes ${{ matrix.version }}
- name: Clean up build artifacts before syncing
run: dotnet clean stage/dotnet/dotnet-sdk-enterprise-server/GitHub.Octokit.sln
- name: Clone the existing repository and check out appropriate branch (create it if it doesn't exist)
run: |
cd ../
git clone https://github.com/octokit/dotnet-sdk-enterprise-server.git
cd dotnet-sdk-enterprise-server
git fetch origin
if git show-ref --verify --quiet refs/remotes/origin/${{ matrix.version }}; then
git switch -c ${{ matrix.version }} --track origin/${{ matrix.version }}
echo "Branch ${{ matrix.version }} already exists; skipping creation and fetching from remote"
else
git switch -c ${{ matrix.version }}
echo "Branch ${{ matrix.version }} does not exist on remote; created locally"
git switch -
fi
cd ../
- name: Copy generated code to downstream repository
run: |
cp -rf stage/dotnet/dotnet-sdk-enterprise-server/. ../dotnet-sdk-enterprise-server/ # copy everything
rsync -av --delete stage/dotnet/dotnet-sdk-enterprise-server/src/ ../dotnet-sdk-enterprise-server/src/ # delete files that are not generated
- uses: gr2m/create-or-update-pull-request-action@cd-path
if: github.event_name != 'pull_request' # do not update the SDK on PR builds
env:
GITHUB_TOKEN: ${{ secrets.OCTOKITBOT_SDK_PAT }}
with:
title: "GHES ${{ matrix.version}}: Changes in generated code"
body: >
The latest OpenAPI spec resulted in changes to the generated code. Please review, set an applicable
commit message, merge, and tag a release as appropriate.
base-branch: ${{ matrix.version }}
branch: "generated-code-update-${{ matrix.version }}"
author: "Octokit Bot <security+octokitbot@github.com>"
commit-message: "New updates to generated code"
repository: "octokit/dotnet-sdk-enterprise-server"
path-to-cd-to: "../dotnet-sdk-enterprise-server"