Skip to content

Windows 32/64 Github Action Builds #166

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

Merged
merged 4 commits into from
Mar 10, 2023

Conversation

yinzara
Copy link
Contributor

@yinzara yinzara commented Mar 9, 2023

Fixes #142

This PR includes minor changes to the Bazel build process and new GitHub Actions/Workflows to facilitate building the Windows 32/64 release zip files using the Visual Studio toolset ensuring it's compatibility on all Windows systems (not just in minGW). The Bazel changes should be compatible with existing internal build processes and should not affect the non-Windows releases controlled by Google's internal build system. They are only so we can pass the "--cpu" argument in Github Actions and properly name the output release file.

See the release created by the tag submitted with this PR at:
https://github.com/yinzara/protobuf-javascript/releases/v3.21.2

I was actually successful in building the Mac OS x86/ARM and Linux x86_64 releases as well.
https://github.com/yinzara/protobuf-javascript/releases/tag/v3.21.2-yinzara-2

Unfortunately building the other architectures would either require a new toolchain or potentially using https://github.com/uraimo/run-on-arch-action. However, either was beyond the scope I was tackling and both wouldn't be able to produce the x86_32 architecture.

I've disabled the Mac OS and Linux builds in the github action workflow file for now (with comment explaining why).

If a release was already created via an internal tool before the tag is pushed to Github, this should properly add to the existing release (instead of creating a new one) because of the svenstaro/upload-release-action@v2 behavior.

I tested this by rerunning the release step of the build and it only updated the executables without creating a new release.
Initial release:
https://github.com/yinzara/protobuf-javascript/actions/runs/4379577450/attempts/1

Rebuild:
https://github.com/yinzara/protobuf-javascript/actions/runs/4379577450

I suggest after this PR is merged that someone take the auto build win32/win64.zip files and update the existing 3.21.2 release so that people downloading the new files will have the fixed version that works in Powershell and Windows apps.

@dibenede dibenede self-requested a review March 9, 2023 23:15
key: bazel

- name: Install protoc
uses: arduino/setup-protoc@v1
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we can use this for security reasons. Can you do something like this instead?

https://github.com/protocolbuffers/protobuf-javascript/blob/main/.github/workflows/codeql.yml#L61-L68

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure. That will probably make it so I can completely skip the custom action but I'll see.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've now completely removed the arduino/setup-protoc dep and standardized the download of the protoc executable/includes between build.yml and codeql.yml

Should you want to update the version, you can now just copy and paste the top environment variable between the two files easily.

This also simplified the actual codeql.yml config as well into separate steps.

@dibenede
Copy link
Contributor

dibenede commented Mar 9, 2023

Overall this looks fantastic. Thank you for putting it together!

- name: Install Protoc
run: |
echo "Fetching protoc"
curl --header 'Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}' \
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This ensures we don't get rate capped for any reason (not that we would :))

-L https://github.com/protocolbuffers/protobuf/releases/download/v${PROTOC_VERSION}/protoc-${PROTOC_VERSION}-${PROTOC_PLATFORM}.zip \
--output protoc-release.zip
unzip protoc-release.zip -d protoc-release
rm protoc-release.zip
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There was no need for that whole $GITHUB_WORKSPACE stuff since it's all being executed in that directory as it is.

name: js
path: |
google-protobuf.js
google
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These generated files should be the same no matter what platform we package the "protoc-gen-js/.exe" for so we can use the same assets

unzip $GITHUB_WORKSPACE/protoc-release.zip -d $GITHUB_WORKSPACE/protoc-release
echo "Clean, install, and test protobuf-javascript"
npm ci
npm install
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

npm ci and npm install are the same except that npm install can modify the package-lock.json. npm ci does not so you should just use that.

)

config_setting(
name = "k8",
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Technically not required for the windows build but it doesn't hurt anything so I left it here so you can strill build the linux-x86_64 build using --cpu k8

Copy link
Contributor

@dibenede dibenede left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you so much for all your help!

@dibenede dibenede merged commit 566f359 into protocolbuffers:main Mar 10, 2023
@yinzara
Copy link
Contributor Author

yinzara commented Mar 13, 2023

Any chance we could get the existing win32 and win64 zip files in the 3.21.2 release updated with the versions built by the main action build?

@dibenede
Copy link
Contributor

Yes, planning to, just ran out of time the other day. I'll ping the bug thread when it's done.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Issue Occurring running protoc-gen-js command on windows 11
2 participants