Skip to content

Commit

Permalink
github: different archive formats per target OS
Browse files Browse the repository at this point in the history
  • Loading branch information
JamesDunne committed Mar 12, 2022
1 parent 6e733ad commit 502dc35
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 25 deletions.
45 changes: 31 additions & 14 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,26 +27,30 @@ jobs:

release-matrix:
strategy:
fail-fast: true
fail-fast: false
matrix:
include:
- os: macos-latest
goos: darwin
goarch: amd64
suffix: tar.gz
#- os: macos-latest
# goos: darwin
# goarch: arm64
- os: windows-latest
goos: windows
goarch: amd64
exesuffix: .exe
suffix: zip
- os: windows-latest
goos: windows
goarch: "386"
exesuffix: .exe
suffix: zip
- os: ubuntu-latest
goos: linux
goarch: amd64
suffix: tar.xz
#- os: ubuntu-latest
# goos: linux
# goarch: "386"
Expand Down Expand Up @@ -118,20 +122,33 @@ jobs:
run: >
GOARCH=${{matrix.goarch}} go build
-ldflags="-X 'main.version=${{env.GITHUB_REF_SLUG}}' -X 'main.commit=${{env.GITHUB_SHA_SHORT}}' -X 'main.date=$(date +'%Y-%m-%dT%H:%M:%S')'"
-o ./${{env.basename}}/sni${{matrix.exesuffix}}
-o ./${{env.basename}}/sni
./cmd/sni
# cross-platform tar.gz creator:
- name: Create ${{env.basename}}.tar.gz
run: >
go run
.github/scripts/tar.go
-z
-o ${{env.basename}}.tar.gz
-strip ${{env.basename}}/
${{env.basename}}/
- uses: actions/upload-artifact@v1
#- name: Create ${{env.basename}}.tar.gz
# run: >
# go run
# .github/scripts/tar.go
# -z
# -o ${{env.basename}}.tar.gz
# -strip ${{env.basename}}/
# ${{env.basename}}/

- name: Package ${{env.basename}}.${{matrix.suffix}}
if: ${{ matrix.os == 'macos-latest' }}
run: tar czf ${{env.basename}}.${{matrix.suffix}} ${{env.basename}}/

- name: Package ${{env.basename}}.${{matrix.suffix}}
if: ${{ matrix.os == 'windows-latest' }}
run: Compress-Archive -DestinationPath ${{env.basename}}.${{matrix.suffix}} -Path ${{env.basename}}/*

- name: Package ${{env.basename}}.${{matrix.suffix}}
if: ${{ matrix.os == 'ubuntu-latest' }}
run: tar cJf ${{env.basename}}.${{matrix.suffix}} ${{env.basename}}/

- name: Upload artifact
uses: actions/upload-artifact@v1
with:
name: ${{env.basename}}.tar.gz
path: ${{ github.workspace }}/${{env.basename}}.tar.gz
name: ${{env.basename}}.${{matrix.suffix}}
path: ${{github.workspace}}/${{env.basename}}.${{matrix.suffix}}
38 changes: 27 additions & 11 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,20 +32,24 @@ jobs:
- os: macos-latest
goos: darwin
goarch: amd64
suffix: tar.gz
#- os: macos-latest
# goos: darwin
# goarch: arm64
- os: windows-latest
goos: windows
goarch: amd64
exesuffix: .exe
suffix: zip
- os: windows-latest
goos: windows
goarch: "386"
exesuffix: .exe
suffix: zip
- os: ubuntu-latest
goos: linux
goarch: amd64
suffix: tar.xz
#- os: ubuntu-latest
# goos: linux
# goarch: "386"
Expand Down Expand Up @@ -117,24 +121,36 @@ jobs:
run: >
GOARCH=${{matrix.goarch}} go build
-ldflags="-X 'main.version=${{env.GITHUB_REF_SLUG}}' -X 'main.commit=${{env.GITHUB_SHA_SHORT}}' -X 'main.date=$(date +'%Y-%m-%dT%H:%M:%S')'"
-o ./${{env.basename}}/sni${{matrix.exesuffix}}
-o ./${{env.basename}}/sni
./cmd/sni
# cross-platform tar.gz creator:
- name: Create ${{env.basename}}.tar.gz
run: >
go run
.github/scripts/tar.go
-z
-o ${{env.basename}}.tar.gz
-strip ${{env.basename}}/
${{env.basename}}/
#- name: Create ${{env.basename}}.tar.gz
# run: >
# go run
# .github/scripts/tar.go
# -z
# -o ${{env.basename}}.tar.gz
# -strip ${{env.basename}}/
# ${{env.basename}}/

- name: Package ${{env.basename}}.${{matrix.suffix}}
if: ${{ matrix.os == 'macos-latest' }}
run: tar czf ${{env.basename}}.${{matrix.suffix}} ${{env.basename}}/

- name: Package ${{env.basename}}.${{matrix.suffix}}
if: ${{ matrix.os == 'windows-latest' }}
run: Compress-Archive -DestinationPath ${{env.basename}}.${{matrix.suffix}} -Path ${{env.basename}}/*

- name: Package ${{env.basename}}.${{matrix.suffix}}
if: ${{ matrix.os == 'ubuntu-latest' }}
run: tar cJf ${{env.basename}}.${{matrix.suffix}} ${{env.basename}}/

- name: Upload binaries to release
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
tag: ${{ env.GITHUB_REF_SLUG }}
overwrite: true
asset_name: ${{env.basename}}.tar.gz
file: ${{ github.workspace }}/${{env.basename}}.tar.gz
asset_name: ${{env.basename}}.${{matrix.suffix}}
file: ${{ github.workspace }}/${{env.basename}}.${{matrix.suffix}}

0 comments on commit 502dc35

Please sign in to comment.