Skip to content

Add more binary builds, simplify release process#276

Merged
mislav merged 5 commits intomasterfrom
rework-release
Jan 30, 2020
Merged

Add more binary builds, simplify release process#276
mislav merged 5 commits intomasterfrom
rework-release

Conversation

@mislav
Copy link
Copy Markdown
Contributor

@mislav mislav commented Jan 29, 2020

This adds

  • 32-bit builds for Linux and Windows
  • .zip instead of .exe for Windows
  • Homebrew formula support for Linux

I have chosen to provide .zip archives for Windows to enable bundling more files with a release for the future, such as HTML help files. Providing .zip archives also enables scripted installs such as via community-maintained Chocolatey/Scoop formulas in the long term, whereas I doubt that scripts are able to fetch & unpack files from MSI installers in the same way.

This PR changes

  • Releases are no longer copied to github/homebrew-gh as there is no need for that anymore;
  • Homebrew formula is now bumped by goreleaser directly, instead of using a separate workflow step;
  • All our custom Actions are now obsolete and therefore cleaned up. 🔥

Now that there is a ZIP archive to download, to avoid the complexities
of unzipping through Node.js we use hub to download the `.zip`, extract
it, and eventually upload the `.msi` back to the release.

- name: Check out code into the Go module directory
uses: actions/checkout@v1
uses: actions/checkout@v2
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

checkout@v2 is faster and has more features than checkout@v1, such as easy pushing back to the repository

- name: Generate changelog
run: script/changelog | tee CHANGELOG.md
run: |
git fetch --unshallow
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This is needed when generating changelog since checkout@v2 is shallow by default

GH_OAUTH_CLIENT_ID: 178c6fc778ccc68e1d6a
GH_OAUTH_CLIENT_SECRET: ${{secrets.OAUTH_CLIENT_SECRET}}
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
GITHUB_TOKEN: ${{secrets.UPLOAD_GITHUB_TOKEN}}
Copy link
Copy Markdown
Contributor Author

@mislav mislav Jan 29, 2020

Choose a reason for hiding this comment

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

goreleaser now needs to also write to github/homebrew-gh directly, so regular GITHUB_TOKEN won't suffice as it only has privileges to write to this repo

shell: bash
run: |
curl -fsSL https://github.com/github/hub/raw/master/script/get | bash -s 2.14.1
bin/hub release download "${GITHUB_REF#refs/tags/}" -i '*windows_amd64*.zip'
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Now that we're uploading .zip instead of .exe to our relases, I found myself struggling to update the download-exe action accordingly. Instead, I've opted to use hub to make downloading and extracting simpler.

mkdir -p build
msi="$(basename "${{ steps.download_exe.outputs.zip }}" ".zip").msi"
printf "::set-output name=msi::%s\n" "$msi"
go-msi make --msi "$PWD/$msi" --out "$PWD/build" --version "${GITHUB_REF#refs/tags/}"
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Now that the download_exe has changed and already extracts bin/hub.exe in the appropriate place, I've decided to inline the build MSI script since most of what it does is just invokes go-msi with appropriate arguments.

with:
msi-file: ${{ steps.buildmsi.outputs.msi }}
shell: bash
run: bin/hub release edit "${GITHUB_REF#refs/tags/}" -m "" -a "${{ steps.buildmsi.outputs.msi }}"
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Since the upload MSI step only needs to upload a single file and is no longer responsible for deleting the old .exe, I've chosen to just do a hub one-liner here to replace the JS action.

id: macos
goos: [darwin]
goarch: [amd64]
- <<: *build_defaults
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I'm using arcane YAML trickery here to avoid repeating binary, main, and ldflags fields for each of the builds

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

😬


brews:
- name: gh
ids: [nix]
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Homebrew now includes binaries from both macos+linux builds

@vilmibm vilmibm mentioned this pull request Jan 29, 2020
@mislav mislav merged commit 8aa46ab into master Jan 30, 2020
@mislav mislav deleted the rework-release branch January 30, 2020 18:33
@mislav mislav mentioned this pull request Jan 30, 2020
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.

7 participants