Skip to content

Commit

Permalink
cd/releases: create releases with built artifacts in a release profile
Browse files Browse the repository at this point in the history
  • Loading branch information
meschbach committed May 10, 2024
1 parent faa832f commit f33bb99
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 0 deletions.
15 changes: 15 additions & 0 deletions .github/workflows/main.yaml
Expand Up @@ -76,3 +76,18 @@ jobs:
file: cmd/service/Dockerfile
push: true
tags: 'meschbach/pgcqrs:${{ env.BRANCH }}'
- name: Setup Go ${{ matrix.go-version }}
uses: actions/setup-go@v5
with:
go-version: '1.22'
- name: Building release artifacts
run: |
./release.sh
- name: Github Release
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ steps.version.outputs.tag }}
fail_on_unmatched_files: true
generate_release_notes: true
files: |
pgcqrs*.tgz
30 changes: 30 additions & 0 deletions release.sh
@@ -0,0 +1,30 @@
#!/bin/bash

set -xe


compile() {
local name=$1
local arch=$2
local cmd=$3
CGO_ENABLED=0 GOOS=linux GOARCH=$arch go build -ldflags='-w -s -extldflags "-static"' -o $name $cmd
}

compile_and_archive() {
local name=$1
local arch=$2
local cmd=$3
compile $name $arch $cmd
tar czvf $name_$arch.tgz $name_$arch
}

for arch in amd64 arm64
do
for os in linux darwin
do
CGO_ENABLED=0 GOOS=$os GOARCH=$arch go build -ldflags='-w -s -extldflags "-static"' -o service ./cmd/service
CGO_ENABLED=0 GOOS=$os GOARCH=$arch go build -ldflags='-w -s -extldflags "-static"' -o pgcqrs ./cmd/pgcqrs
CGO_ENABLED=0 GOOS=$os GOARCH=$arch go build -ldflags='-w -s -extldflags "-static"' -o migrator ./cmd/migrator
tar zcvf pgcqrs_$os_$arch.tgz service pgcqrs migrator migrations/
done
done

0 comments on commit f33bb99

Please sign in to comment.