Skip to content

GA: fix paths

GA: fix paths #38

name: Create GH release
on:
push:
tags:
- "*"
permissions:
contents: write
jobs:
build:
name: Build for ${{ matrix.goos }} ${{ matrix.arch_name }}
runs-on: ubuntu-latest
strategy:
matrix:
include:
- goos: darwin
goarch: amd64
arch_name: x64
- goos: darwin
goarch: arm64
arch_name: arm64
- goos: linux
goarch: amd64
arch_name: x64
- goos: linux
goarch: arm64
arch_name: arm64
- goos: windows
goarch: amd64
arch_name: x64
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: "1.21.2"
- name: Get Salami version
id: salami-version
run: echo "version=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT
- name: Get binary name
id: get-binary-name
run: |
echo "binary-name=salami-${{ steps.salami-version.outputs.version }}-${{ matrix.goos }}-${{ matrix.arch_name }}" >> $GITHUB_OUTPUT
- name: Build binary
run: |
GOOS=${{ matrix.goos }} \
GOARCH=${{ matrix.goarch }} \
go build -o ${{ steps.get-binary-name.outputs.binary-name }}
working-directory: ./cli
- name: Upload binary artifact
uses: actions/upload-artifact@v3
with:
name: ${{ steps.get-binary-name.outputs.binary-name }}
path: cli/${{ steps.get-binary-name.outputs.binary-name }}
if-no-files-found: error
verify-version:
name: Verify version
needs: build
runs-on: ubuntu-latest
steps:
- name: Get Salami version
id: salami-version
run: echo "version=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT
- name: Download binary artifacts
uses: actions/download-artifact@v3
with:
name: salami-${{ steps.salami-version.outputs.version }}-linux-x64
- name: Verify version
run: |
version_from_tag=${{ steps.salami-version.outputs.version }}
chmod +x ./salami-$version_from_tag-linux-x64
version_from_binary=$(./salami-$version_from_tag-linux-x64 version | awk '{print $3}')
if [ "$version_from_binary" != "$version_from_tag" ]; then
echo "Version mismatch: $version_from_binary != $version_from_tag"
exit 1
fi
create-release:
name: Create draft release
needs:
- build
- verify-version
runs-on: ubuntu-latest
steps:
- name: Download binary artifacts
uses: actions/download-artifact@v3
- name: Get Salami version
id: salami-version
run: echo "version=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT
- name: Create release
uses: softprops/action-gh-release@v1
env:
VERSION: ${{ steps.salami-version.outputs.version }}
with:
draft: true
prerelease: ${{ contains(github.ref, '-rc') }}
fail_on_unmatched_files: true
files: |
salami-${{ env.VERSION }}-darwin-x64/salami-${{ env.VERSION }}-darwin-x64
salami-${{ env.VERSION }}-darwin-arm64/salami-${{ env.VERSION }}-darwin-arm64
salami-${{ env.VERSION }}-linux-x64/salami-${{ env.VERSION }}-linux-x64
salami-${{ env.VERSION }}-linux-arm64/salami-${{ env.VERSION }}-linux-arm64
salami-${{ env.VERSION }}-windows-x64/salami-${{ env.VERSION }}-windows-x64