-
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
Conversation
.github/workflows/main.yml
Outdated
with: | ||
name: Docs.zip | ||
path: ${{ github.workspace }}/Realm/packages/Docs.zip | ||
retention-days: ${{ github.event_name != 'pull_request' && 30 || 1 }} |
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.
I'm not sure the amount of days we'd like to retain the docs. So I just put the standard length we always use. Please, advise if 30 days are too many.
.github/workflows/release.yml
Outdated
echo "RELEASE_VERSION=$version" | Out-File $env:GITHUB_ENV -Encoding utf8 | ||
- name: Upload to nuget | ||
run: | | ||
dotnet nuget push "Realm/packages/Realm.Fody.$env:RELEASE_VERSION/Realm.Fody.$env:RELEASE_VERSION.nupkg" --skip-duplicate --api-key ${{ secrets.NUGET_API_KEY }} --source https://api.nuget.org/v3/index.json |
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.
This folder within packages
is because I decided to download all artifacts. When doing so, by specifications, a folder per artifact is created and each artifact is appropriately placed.
.github/workflows/release.yml
Outdated
- name: Extract release name | ||
run: | | ||
$nupkgName = ls Realm/packages/Realm.Fody.$env:RELEASE_VERSION | select -expandproperty Name | Select-String Fody | ||
$nupkgName -match "(?sm)\d{1,2}\.\d{1,2}\.\d{1,2}" |
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.
Will that regex (and the one above) match beta versions?
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.
Good point. I'm gonna fix that.
.github/workflows/release.yml
Outdated
$nupkgName = ls Realm/packages/Realm.Fody.$env:RELEASE_VERSION | select -expandproperty Name | Select-String Fody | ||
$nupkgName -match "(?sm)\d{1,2}\.\d{1,2}\.\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 comment
The 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 comment
The 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 comment
The 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.
There's a thing I've been debating about: checking for error/warning in the executed commands. Generally we don't need to do any check on shell command return values, since when a command fails then the step automatically fails, too, consequently making the whole workflow fail, unless instructed otherwise. But there's a problem, if the command doesn't really fail but returns warnings or for some strange reason it "fails" but not enough to report a non-zero return value then it'll be hard to notice. So, the conclusion is: just sometimes GH runners don't understand warnings or errors aren't really non-zero return values (althogh I have no example for this second case). What should we do about this?
What's your opinion on the matter? |
* master: Update the AppConfiguration.Logger obsolete message (#2495) Add more serializer types to the preserved ones (#2489) Update changelog from Core (#2488) Build an xcframework for iOS (#2475) Prepare for vNext (#2487) Prepare for 10.2.1 (#2484) Fix TableKey / ObjKey conversion on Android x86 (#2477) Update the build manager locations (#2474) Clean up native resources on Unity application exit (#2467) Fix some native warnings (#2483) Don't try to get the app from a removed user (#2480) Use delete_files from core when deleting a Realm. (#2401) Fixes for the sync datatype tests (#2461) Clean up the package.json and add some docs (#2452) Run iOS tests on CI (#2405) Verify that objects do not belong to different realm when added to collection (#2465) Updated README instructions (#2459)
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.
Added 2 minor comments and some explanation for the changes I made to get the generated docs to resolve references correctly.
.github/templates/Readme.md
Outdated
1. Download the executable for your platform from the [releases page](https://github.com/vmware-tanzu/carvel-ytt/releases). | ||
1. Rename it to `ytt`. | ||
1. Place it in your PATH. | ||
|
||
## Building the docs | ||
1. In `$SolutionDir/.github/templates` run `ytt -f main.yml --output-files ../workflows/`. | ||
1. `cd $SolutionDir/.github/templates` | ||
1. `ytt -f . --output-files ../workflows/` ==> to target all files<br/> |
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:
- Specifically adding a line break tag (like a did)
- Ending a line with 2 or more spaces and a new line char
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?
- 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 comment
The 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 comment
The reason will be displayed to describe this comment to others. Learn more.
I want to double check that I got this right:
Our main workflow is triggered with push on master/main and on pull_request (with events opened, synchronize, or reopened). Since ref
defaults to the reference or SHA of the event that triggered the workflow, you're saying that we need to avoid to fetch a push to master, which generally happens to be a merge of a pull request, but we always need to carefully fetch the head of the current PR which could be lacking the latest merged PRs that master has, which is a good thing in this case.
Did I get this right?
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.
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 comment
The 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.
.github/templates/main.yml
Outdated
- 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 comment
The 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.
- #@ template.replace(fetchWrapperBinaries()) | ||
- #@ template.replace(buildPackages()) | ||
- #@ findPackageVersion() | ||
- #@ template.replace(buildDocs()) |
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.
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 comment
The reason will be displayed to describe this comment to others. Learn more.
🤦🏻.... makes sense
.github/workflows/release.yml
Outdated
$nupkgName = ls Realm/packages/Realm.Fody.$env:RELEASE_VERSION | select -expandproperty Name | Select-String Fody | ||
$nupkgName -match "(?sm)\d{1,2}\.\d{1,2}\.\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 comment
The 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.
Description
This PR adds a workflow that automates the whole release process of the .NET SDK from Github Actions.
Fixes #2051
TODO