-
Notifications
You must be signed in to change notification settings - Fork 3
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
Fix Github Workflows #2
Changes from all commits
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 |
---|---|---|
|
@@ -6,46 +6,103 @@ on: | |
version: | ||
description: 'Go version to build ("1.17")' | ||
required: true | ||
prerelease: | ||
description: 'Is this a pre-release?' | ||
required: true | ||
default: 'false' | ||
|
||
jobs: | ||
build: | ||
strategy: | ||
matrix: | ||
include: | ||
- builder: ubuntu-latest | ||
goos: linux | ||
goarch: amd64 | ||
- builder: macos-latest | ||
goos: darwin | ||
goarch: amd64 | ||
goarch: arm64 | ||
- builder: macos-latest | ||
goos: darwin | ||
goarch: arm64 | ||
goarch: amd64 | ||
- builder: ubuntu-latest | ||
goos: linux | ||
goarch: amd64 | ||
- builder: windows-latest | ||
goos: windows | ||
goarch: amd64 | ||
|
||
runs-on: ${{ matrix.builder }} | ||
outputs: | ||
built_version: ${{ steps.encore_go_version.outputs.version }} | ||
steps: | ||
- name: Check out repo | ||
uses: actions/checkout@v2 | ||
with: | ||
fetch-depth: 0 # We need the full history for the Go submodule | ||
submodules: true # Checkout the Go submodule | ||
|
||
- name: Set up Go | ||
uses: actions/setup-go@v2 | ||
with: | ||
go-version: 1.17 | ||
|
||
- name: 'Create patched runtime' | ||
run: bash ./apply_patch.bash "${{ github.event.inputs.version }}" | ||
env: | ||
GO111MODULE: "on" | ||
|
||
- name: Build | ||
run: go run . -dst=dist -goos=${{ matrix.goos }} -goarch=${{ matrix.goarch }} | ||
env: | ||
GO111MODULE: "on" | ||
|
||
# This step gets the exact version of Go we're releasing (including minor), so if we give the input as `1.17` this might return `encore-go1.17.5`. | ||
- name: 'Read the version of Go we built' | ||
id: encore_go_version | ||
run: echo "::set-output name=version::$(go run . --read-built-version)" | ||
|
||
- name: 'Tar artifacts' | ||
run: tar -czvf encore-go-${{ github.event.inputs.version }}-${{ matrix.goos }}_${{ matrix.goarch }}.tar.gz -C dist/${{ matrix.goos }}_${{ matrix.goarch }} . | ||
- name: Publish artifact | ||
run: tar -czvf ${{ steps.encore_go_version.outputs.version }}-${{ matrix.goos }}_${{ matrix.goarch }}.tar.gz -C dist/${{ matrix.goos }}_${{ matrix.goarch }} . | ||
|
||
- name: 'Upload build artifact' | ||
uses: actions/upload-artifact@v2 | ||
with: | ||
name: encore-go-${{ github.event.inputs.version }}-${{ matrix.goos }}_${{ matrix.goarch }} | ||
path: encore-go-${{ github.event.inputs.version }}-${{ matrix.goos }}_${{ matrix.goarch }}.tar.gz | ||
name: ${{ steps.encore_go_version.outputs.version }}-${{ matrix.goos }}_${{ matrix.goarch }} | ||
path: ${{ steps.encore_go_version.outputs.version }}-${{ matrix.goos }}_${{ matrix.goarch }}.tar.gz | ||
release: | ||
runs-on: ubuntu-latest | ||
needs: build | ||
steps: | ||
- name: 'Download artifacts from build steps' | ||
uses: actions/download-artifact@v2 | ||
|
||
- name: 'Convert windows artifact to zip' | ||
run: | | ||
cd ${{needs.build.outputs.built_version}}-windows_amd64 | ||
tar -xzf ${{needs.build.outputs.built_version}}-windows_amd64.tar.gz | ||
zip -r ${{needs.build.outputs.built_version}}-windows_amd64.zip encore-go | ||
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 created a zip version just to be nicer to Windows users who might not be used to working with |
||
|
||
- name: 'Move, rename and create checksums for the artifacts' | ||
run: | | ||
mkdir output | ||
mv ${{needs.build.outputs.built_version}}-linux_amd64/${{needs.build.outputs.built_version}}-linux_amd64.tar.gz output/Linux_x86-64.tar.gz | ||
mv ${{needs.build.outputs.built_version}}-darwin_amd64/${{needs.build.outputs.built_version}}-darwin_amd64.tar.gz output/macOS_x86-64.tar.gz | ||
mv ${{needs.build.outputs.built_version}}-darwin_arm64/${{needs.build.outputs.built_version}}-darwin_arm64.tar.gz output/macOS_arm64.tar.gz | ||
mv ${{needs.build.outputs.built_version}}-windows_amd64/${{needs.build.outputs.built_version}}-windows_amd64.tar.gz output/Windows_x86-64.tar.gz | ||
mv ${{needs.build.outputs.built_version}}-windows_amd64/${{needs.build.outputs.built_version}}-windows_amd64.zip output/Windows_x86-64.zip | ||
cd output | ||
sha256sum * > checksums.txt | ||
ls -R . | ||
mv * ../ | ||
cd .. | ||
cat checksums.txt | ||
|
||
- name: 'Publish release' | ||
uses: DomBlack/[email protected] | ||
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 created a fork of |
||
with: | ||
token: ${{ secrets.GITHUB_TOKEN }} | ||
tag: ${{ needs.build.outputs.built_version }} | ||
name: ${{ needs.build.outputs.built_version }} | ||
body: > | ||
This release is the compiled version of ${{ needs.build.outputs.built_version }} | ||
draft: false | ||
allow_override: true | ||
prerelease: ${{ github.event.inputs.prerelease }} | ||
gzip: false | ||
files: Linux_x86-64.tar.gz Windows_x86-64.tar.gz Windows_x86-64.zip macOS_arm64.tar.gz macOS_x86-64.tar.gz checksums.txt | ||
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 went with these file names rather than the Go ARCH names so it's harder to mistakenly get an |
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.
Note; I did this via the
main.go
file so it works on Windows as well as MacOS & Linux (and doesn't need us to write separate powershell code vs bash code)