-
Notifications
You must be signed in to change notification settings - Fork 165
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Automate SDK release from CI #2457
Changes from 29 commits
dbf7400
e6b55cc
e21f709
e186ef7
da17089
e936664
4bf8118
33e6b21
d7825bd
38c1e5d
0d0010e
9848ff9
9a9cd6e
3571f63
a3fc1b6
ea2214b
3598d87
0919697
652fb51
b296c37
8ce7465
e1090d8
8a02492
c12133c
9a2f219
491df05
d80346b
6e306c7
b327cc7
8c0a3fd
36b5358
17b42c3
a3d9617
6c812b7
d4e1607
357b341
816fc7b
fb552e5
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -30,11 +30,8 @@ if: #@ wrappersCacheCondition | |
#@ def setupVcpkg(): | ||
name: Setup Vcpkg | ||
run: | | ||
Write-Output 'Beginning download...' | ||
Invoke-WebRequest -Uri https://static.realm.io/downloads/vcpkg.zip -OutFile C:\vcpkg.zip | ||
Write-Output ((Get-Item C:\vcpkg.zip).length/1MB) | ||
Expand-Archive -Path C:\vcpkg.zip -DestinationPath C:\ | ||
Write-Output 'Completed!' | ||
shell: powershell | ||
if: #@ wrappersCacheCondition + " && steps.check-vcpkg-cache.outputs.cache-hit != 'true'" | ||
#@ end | ||
|
@@ -50,7 +47,7 @@ if: #@ wrappersCacheCondition + " && steps.check-vcpkg-cache.outputs.cache-hit ! | |
#@ actualCommand = cmd + configurationParam + ltoParam | ||
|
||
steps: | ||
- #@ template.replace(checkoutCode()) | ||
- #@ template.replace(checkoutCode("recursive")) | ||
- #@ checkCache(cacheKey) | ||
#@ for step in intermediateSteps: | ||
- #@ step | ||
|
@@ -66,11 +63,12 @@ steps: | |
retention-days: 1 | ||
#@ end | ||
|
||
#@ def checkoutCode(): | ||
#@ def checkoutCode(submodules=False): | ||
nirinchev marked this conversation as resolved.
Show resolved
Hide resolved
|
||
- name: Checkout code | ||
uses: actions/checkout@v2 | ||
with: | ||
submodules: recursive | ||
submodules: #@ submodules | ||
ref: ${{ github.event.pull_request.head.sha }} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This changes the behavior of checkout@v2 to checkout the HEAD rather than the merge commit - this is useful in regular PRs, but especially important for releases, where we don't want to build the merged thing. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I want to double check that I got this right: There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The default behavior for checkout on a PR trigger is to checkout the merge commit (i.e. have the PR branch merged into the base branch and use that). This is why when there are merge conflicts, our GHA workflows don't run. This is the change suggested in the checkout action docs to make sure that PR builds actually build and test the code that is in the PR itself. While for PR builds against master, checking out the merge commit is not a big deal - and in some cases may even be useful - for release PRs it's plain wrong and may result in very surprising behavior where we actually push a nuget package containing code that was not present in the release branch. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Now it all makes sense. I wasn't fully aware of the default behaviour for the checkout on PRs, that's why I got confused. Thank you for the explanation. On top of this, the change of line 74 will stop "there are merge conflicts with master" that prevent the workflow to run; which I'm actually rather happy about. |
||
- name: Register csc problem matcher | ||
run: echo "::add-matcher::.github/problem-matchers/csc.json" | ||
- name: Register msvc problem matcher | ||
|
@@ -101,6 +99,35 @@ steps: | |
retention-days: ${{ github.event_name != 'pull_request' && 30 || 1 }} | ||
#@ end | ||
|
||
#@ def buildDocs(): | ||
#@ docsCondition = "${{ !contains(github.ref, 'release') }}" | ||
- name: Check Docfx cache | ||
if: #@ docsCondition | ||
id: check-docfx-cache | ||
uses: actions/cache@v2 | ||
with: | ||
path: 'C:\docfx' | ||
key: docfx | ||
- name: Download docfx | ||
if: #@ docsCondition + " && steps.check-docfx-cache.outputs.cache-hit != 'true'" | ||
run: | | ||
Invoke-WebRequest -Uri https://github.com/dotnet/docfx/releases/download/v2.58/docfx.zip -OutFile C:\docfx.zip | ||
Expand-Archive -Path C:\docfx.zip -DestinationPath C:\docfx | ||
shell: powershell | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Rather than use choco, we're caching docfx to avoid downloading it every time. This seems to cut docs build times from 70 to 35 seconds. |
||
- name: Build docs | ||
if: #@ docsCondition | ||
run: | | ||
C:\docfx\docfx Docs/docfx.json | ||
Compress-Archive -Path Docs/_site -DestinationPath "Realm/packages/Docs.zip" | ||
- name: Store docs artifacts | ||
if: #@ docsCondition | ||
uses: actions/upload-artifact@v2 | ||
with: | ||
name: Docs.zip | ||
path: ${{ github.workspace }}/Realm/packages/Docs.zip | ||
retention-days: ${{ github.event_name != 'pull_request' && 30 || 1 }} | ||
#@ end | ||
|
||
#@ def uploadPackageArtifacts(): | ||
#@ for pkgName in nugetPackages: | ||
#@ finalPkgName = pkgName + ".${{ steps.find-nupkg-version.outputs.package_version }}.nupkg" | ||
|
@@ -114,13 +141,13 @@ steps: | |
#@ end | ||
|
||
#@ def fetchPackageArtifacts(): | ||
#@ for pkg in [ "Realm", "Realm.Fody" ]: | ||
#@ for pkg in [ "Realm", "Realm.Fody" ]: | ||
- name: #@ "Fetch " + pkg | ||
uses: actions/download-artifact@v2 | ||
with: | ||
name: #@ pkg + ".${{ needs.build-packages.outputs.package_version }}.nupkg" | ||
path: ${{ github.workspace }}/Realm/packages/ | ||
#@ end | ||
#@ end | ||
#@ end | ||
|
||
#@ def deleteTempPackageArtifacts(): | ||
|
@@ -288,10 +315,24 @@ jobs: | |
- name: Set version suffix | ||
id: set-version-suffix | ||
#! Build suffix is PR-1234.5 for PR builds or alpha.123 for branch builds. | ||
run: echo "::set-output name=build_suffix::${{ github.event_name == 'pull_request' && format('PR-{0}', github.event.number) || 'alpha'}}.${{ github.run_number }}" | ||
run: | | ||
$suffix = "" | ||
if ($env:GITHUB_EVENT_NAME -eq "pull_request") | ||
{ | ||
if (-Not $env:GITHUB_REF.Contains("release")) | ||
{ | ||
$suffix = "PR-${{ github.event.number }}.$env:GITHUB_RUN_NUMBER" | ||
nirinchev marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} | ||
} | ||
else | ||
{ | ||
$suffix = "alpha.$env:GITHUB_RUN_NUMBER" | ||
} | ||
echo "::set-output name=build_suffix::$suffix" | ||
- #@ template.replace(fetchWrapperBinaries()) | ||
- #@ template.replace(buildPackages()) | ||
- #@ findPackageVersion() | ||
- #@ template.replace(buildDocs()) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This was the important change that fixed the docs issues - moving it to after the package was built allows docfx to pick up the correct references. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🤦🏻.... makes sense |
||
- #@ template.replace(uploadPackageArtifacts()) | ||
- #@ template.replace(buildUnityPackage()) | ||
run-tests-net-framework: | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
name: release | ||
on: | ||
workflow_dispatch | ||
|
||
jobs: | ||
publish-to-nuget: | ||
runs-on: windows-latest | ||
name: Publish nupkg to nuget | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v2 | ||
- name: Download all artifacts | ||
uses: dawidd6/action-download-artifact@v2 | ||
with: | ||
workflow: main.yml | ||
branch: ${{ github.ref }} | ||
path: ${{ github.workspace }}/Realm/packages/ | ||
- name: Extract release notes | ||
run: | | ||
$changelogContent = Get-Content -Raw -Path "./CHANGELOG.md" | ||
$output_file = "./RELEASE_NOTES.md" | ||
$regex = "(?sm)^(## \d{1,2}\.\d{1,2}\.\d{1,2}(?:-beta\.\d{1,2})? \(\d{4}-\d{2}-\d{2}\))(.+?)(\n## \d{1,2}\.\d{1,2}\.\d{1,2}(?:-beta\.\d{1,2})? \(\d{4}-\d{2}-\d{2}\))" | ||
$changelogContent -match $regex | ||
Set-Content -Path $output_file -Value $Matches[2] | ||
echo "RELEASE_NOTES=$output_file" | Out-File $env:GITHUB_ENV -Encoding utf8 | ||
- name: Extract release name | ||
run: | | ||
$nupkgName = ls "Realm/packages/Realm.Fody.$env:RELEASE_VERSION.nupkg" | select -expandproperty Name | ||
$nupkgName -match "(?sm)\d{1,2}\.\d{1,2}\.\d{1,2}(?:-beta\.\d{1,2})?" | ||
$version = $Matches[0] | ||
echo "RELEASE_VERSION=$version" | Out-File $env:GITHUB_ENV -Encoding utf8 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Rather than use env variables here, I think we should use set-output There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I can do that but, what's the advantage? As a con it has longer syntax, as a pro maybe it's easier to understand where it's set (although a search in the editor achieves the same). What other pros do you see? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I generally dislike env variables as a way of passing data between steps. The step outputs are designed precisely for that and we should prefer to use them. |
||
- name: Upload to nuget | ||
run: | | ||
dotnet nuget push "Realm/packages/Realm.Fody.$env:RELEASE_VERSION.nupkg/Realm.Fody.$env:RELEASE_VERSION.nupkg" --skip-duplicate --api-key ${{ secrets.NUGET_API_KEY }} --source https://api.nuget.org/v3/index.json | ||
dotnet nuget push "Realm/packages/Realm.$env:RELEASE_VERSION.nupkg/Realm.$env:RELEASE_VERSION.nupkg" --skip-duplicate --api-key ${{ secrets.NUGET_API_KEY }} --source https://api.nuget.org/v3/index.json | ||
- name: Create Github Release | ||
uses: ncipollo/release-action@v1 | ||
with: | ||
artifacts: Realm/packages/io.realm.unity-$env:RELEASE_VERSION.tgz/io.realm.unity-$env:RELEASE_VERSION.tgz | ||
bodyFile: ${{ env.RELEASE_NOTES }} | ||
name: "${{ env.RELEASE_VERSION }} - expand with the main features of this release" | ||
commit: ${{ github.ref }} | ||
tag: ${{ env.RELEASE_VERSION }} | ||
token: ${{ secrets.GITHUB_TOKEN }} | ||
draft: true | ||
- name: Upload docs | ||
run: | | ||
Expand-Archive -Path Realm/packages/Docs.zip/Docs.zip -DestinationPath Realm/packages | ||
py -m pip install s3cmd | ||
$versions = $env:RELEASE_VERSION, "latest" | ||
Foreach ($ver in $versions) | ||
{ | ||
s3cmd put --recursive --acl-public --access_key=${{ secrets.DOCS_S3_ACCESS_KEY }} --secret_key=${{ secrets.DOCS_S3_SECRET_KEY }} "${{ github.workspace }}/Realm/packages/_site s3://realm-sdks/realm-sdks/dotnet/$ver/ | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's no need for
<br/>
or is there?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In markdown we can insert a line break in 2 ways:
I thought that in the option number 2 it would be harder to notice the new line. But maybe it's nicer to read? Which approach do you recommend?