fix create-release matrix #130
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Create Release | |
on: | |
push: | |
# Sequence of patterns matched against refs/tags | |
tags: | |
- 'v*' # Push events to matching v*, i.e. v1.0, v20.15.10 | |
jobs: | |
build: | |
name: Build & Upload | |
strategy: | |
matrix: | |
os: [ubuntu-20.04, macos-latest, windows-latest] | |
arch: [amd64] | |
include: | |
- os: ubuntu-20.04 | |
target: "./cmd/longtail/longtail" | |
platform: linux | |
tag: "${GITHUB_REF_NAME}" | |
- os: macos-latest | |
target: "./cmd/longtail/longtail" | |
platform: macos | |
tag: "${GITHUB_REF_NAME}" | |
arch: arm64 | |
- os: windows-latest | |
target: "./cmd/longtail/longtail.exe" | |
platform: win32 | |
tag: "${env:GITHUB_REF_NAME}" | |
runs-on: ${{matrix.os}} | |
steps: | |
- name: Set up Go 1.19 | |
uses: actions/setup-go@v4 | |
with: | |
go-version: 1.19 | |
- name: Check out source code | |
uses: actions/checkout@v3 | |
- name: Build | |
run: | | |
echo "GOARCH: " $GOARCH | |
pushd ./cmd/longtail | |
echo matrix.tag ${{ matrix.tag }} | |
go build -ldflags="-s -w -X 'github.com/DanEngelbrecht/golongtail/commands.BuildVersion=${{ matrix.tag }}'" . | |
popd | |
env: | |
GOARCH: ${{matrix.arch}} | |
CGO_ENABLED: 1 | |
- name: build dist | |
run: | | |
mkdir dist | |
cp ${{matrix.target}} dist/ | |
- name: Upload artifacts | |
uses: actions/upload-artifact@master | |
with: | |
name: dist-${{matrix.platform}}-${{matrix.arch}} | |
path: dist | |
create-release: | |
runs-on: ubuntu-20.04 | |
needs: [build] | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
- name: Download Linux artifacts | |
uses: actions/download-artifact@v1 | |
with: | |
name: dist-linux-amd64 | |
path: dist-linux-amd64 | |
- name: Download MacOs x64 artifacts | |
uses: actions/download-artifact@v1 | |
with: | |
name: dist-macos-amd64 | |
path: dist-macos-amd64 | |
- name: Download MacOs arm64 artifacts | |
uses: actions/download-artifact@v1 | |
with: | |
name: dist-macos-arm64 | |
path: dist-macos-arm64 | |
- name: Download Win32 artifacts | |
uses: actions/download-artifact@v1 | |
with: | |
name: dist-win32-amd64 | |
path: dist-win32-amd64 | |
- name: Rename artifacts | |
run: | | |
cp dist-linux-amd64/longtail longtail-linux-x64 | |
cp dist-macos-amd64/longtail longtail-macos-x64 | |
cp dist-macos-arm64/longtail longtail-macos-arm64 | |
cp dist-win32-amd64/longtail.exe longtail-win32-x64.exe | |
- name: Set execute permission | |
run: | | |
chmod +x longtail-linux-x64 | |
chmod +x longtail-macos-x64 | |
chmod +x longtail-macos-arm64 | |
- name: Zip Linux artifacts | |
uses: montudor/[email protected] | |
with: | |
args: zip -qq -r ./linux-x64.zip ./dist-linux-x64 | |
- name: Zip MacOS x64 artifacts | |
uses: montudor/[email protected] | |
with: | |
args: zip -qq -r ./macos-x64.zip ./dist-macos-x64 | |
- name: Zip MacOS arm64 artifacts | |
uses: montudor/[email protected] | |
with: | |
args: zip -qq -r ./macos-arm64.zip ./dist-macos-arm64 | |
- name: Zip Win32 artifacts | |
uses: montudor/[email protected] | |
with: | |
args: zip -qq -r ./win32-x64.zip ./dist-win32-x64 | |
- name: Check prerelease | |
id: get-prerelease | |
uses: haya14busa/action-cond@v1 | |
with: | |
cond: ${{contains(github.ref, '-pre')}} | |
if_true: "true" | |
if_false: "false" | |
- name: Extract Version Changes | |
run: | | |
sed '1,/^##/!d;/##/d' CHANGELOG.md > CHANGELOG.tmp | |
- name: Read CHANGELOG.tmp | |
id: read_changelog | |
uses: andstor/file-reader-action@v1 | |
with: | |
path: "CHANGELOG.tmp" | |
- name: Create Release | |
id: create_release | |
uses: softprops/action-gh-release@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
tag_name: ${{github.ref.name}} | |
body: | | |
${{steps.read_changelog.outputs.contents}} | |
draft: false | |
prerelease: ${{steps.get-prerelease.outputs.value}} | |
files: | | |
win32-x64.zip | |
linux-x64.zip | |
macos-x64.zip | |
macos-arm64.zip | |
longtail-linux-x64 | |
longtail-macos-x64 | |
longtail-macos-arm64 | |
longtail-win32-x64.exe |