feat: support multile architectures

relates to #323

relates to #298
This commit is contained in:
Jan De Dobbeleer 2021-01-09 13:06:27 +01:00
parent 667151fe28
commit c7bbed1cff

View file

@ -47,13 +47,12 @@ jobs:
strategy: strategy:
matrix: matrix:
os: [ubuntu-latest, macos-latest, windows-latest] os: [ubuntu-latest, macos-latest, windows-latest]
goarch: [amd64]
include: include:
- os: ubuntu-latest - os: ubuntu-latest
ARTIFACT: posh-linux-amd64 goarch: arm64
- os: macos-latest
ARTIFACT: posh-darwin-amd64
- os: windows-latest - os: windows-latest
ARTIFACT: posh-windows-amd64.exe goarch: 386
runs-on: ${{ matrix.os }} runs-on: ${{ matrix.os }}
defaults: defaults:
run: run:
@ -73,16 +72,35 @@ jobs:
run: | run: |
go get -u github.com/kevinburke/go-bindata/... go get -u github.com/kevinburke/go-bindata/...
go generate go generate
- name: Asset name
id: artifact
run: |
if ($IsLinux) {
$artifact = "posh-linux-${{ matrix.goarch }}"
Write-Output "::set-output name=name::$($artifact)"
return
}
if ($IsMacOS) {
$artifact = "posh-darwin-${{ matrix.goarch }}"
Write-Output "::set-output name=name::$($artifact)"
return
}
if ($IsWindows) {
$artifact = "posh-windows-${{ matrix.goarch }}.exe"
Write-Output "::set-output name=name::$($artifact)"
return
}
shell: pwsh
- name: Build - name: Build
id: build id: build
run: go build -o ${{ matrix.ARTIFACT }} -ldflags="-X 'main.Version=${{ needs.release.outputs.version }}'" run: go build -o ${{ steps.artifact.outputs.name }} -ldflags="-X 'main.Version=${{ needs.release.outputs.version }}'"
env: env:
GOARCH: "amd64" GOARCH: ${{ matrix.goarch }}
- name: Hash - name: Hash
id: hash id: hash
run: | run: |
$fileHash = Get-FileHash ${{ matrix.ARTIFACT }} -Algorithm SHA256 $fileHash = Get-FileHash ${{ steps.artifact.outputs.name }} -Algorithm SHA256
$fileHash.Hash | Out-File -Encoding 'UTF8' ${{ matrix.ARTIFACT }}.sha256 $fileHash.Hash | Out-File -Encoding 'UTF8' ${{ steps.artifact.outputs.name }}.sha256
Write-Output "::set-output name=hash_${{ matrix.os }}::$($fileHash.Hash)" Write-Output "::set-output name=hash_${{ matrix.os }}::$($fileHash.Hash)"
shell: pwsh shell: pwsh
- name: Upload Release Asset - name: Upload Release Asset
@ -92,8 +110,8 @@ jobs:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with: with:
upload_url: ${{ needs.release.outputs.upload_url }} upload_url: ${{ needs.release.outputs.upload_url }}
asset_path: src/${{ matrix.ARTIFACT }} asset_path: src/${{ steps.artifact.outputs.name }}
asset_name: ${{ matrix.ARTIFACT }} asset_name: ${{ steps.artifact.outputs.name }}
asset_content_type: application/octet-stream asset_content_type: application/octet-stream
- name: Upload Hash Asset - name: Upload Hash Asset
id: upload-hash-asset id: upload-hash-asset
@ -102,8 +120,8 @@ jobs:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with: with:
upload_url: ${{ needs.release.outputs.upload_url }} upload_url: ${{ needs.release.outputs.upload_url }}
asset_path: src/${{ matrix.ARTIFACT }}.sha256 asset_path: src/${{ steps.artifact.outputs.name }}.sha256
asset_name: ${{ matrix.ARTIFACT }}.sha256 asset_name: ${{ steps.artifact.outputs.name }}.sha256
asset_content_type: text/plain asset_content_type: text/plain
themes: themes:
needs: release needs: release