Skip to content

Commit

Permalink
ci: setup goreleaser (#19)
Browse files Browse the repository at this point in the history
  • Loading branch information
igor-sirotin committed May 17, 2024
1 parent 428b958 commit e4fcdb5
Show file tree
Hide file tree
Showing 7 changed files with 217 additions and 1 deletion.
4 changes: 4 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ on:
branches: [ "main" ]
pull_request:

concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true

jobs:

test:
Expand Down
111 changes: 111 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
name: release

on:
push:
tags:
- v*.*.*

concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true

jobs:

# TODO: refactor with matrix strategy?

darwin:
runs-on: macos-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: '1.20'

- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v5
with:
distribution: goreleaser
args: release --skip-publish --clean --config=ci/.goreleaser-darwin.yml

- name: Upload
uses: actions/upload-artifact@v4
with:
name: ls2sp-darwin
path: dist/waku-poker-planning-go*.tar.gz

linux:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Install compiler
run: sudo apt-get -y install gcc-aarch64-linux-gnu

- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: '1.20'

- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v5
with:
distribution: goreleaser
args: release --skip-publish --clean --config=ci/.goreleaser-linux.yml
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Upload
uses: actions/upload-artifact@v4
with:
name: ls2sp-linux
path: dist/waku-poker-planning-go*.tar.gz

# windows:
# runs-on: windows-latest
# steps:
# - uses: actions/checkout@v4
# with:
# fetch-depth: 0
#
# - name: Set up Go
# uses: actions/setup-go@v5
# with:
# go-version: '1.20'
#
# - name: Run GoReleaser
# uses: goreleaser/goreleaser-action@v5
# with:
# distribution: goreleaser
# args: build --clean --config=ci/.goreleaser-windows.yml
# env:
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

draft-release:
needs: [darwin, linux]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Make directories
run: |
mkdir -p ./ls2sp-build
- name: Download binaries
uses: actions/download-artifact@v4
with:
path: ./ls2sp-build

- name: Release
uses: goreleaser/goreleaser-action@v2
with:
args: release --config=ci/.goreleaser.yml
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
.idea/
.idea/
dist
25 changes: 25 additions & 0 deletions ci/.goreleaser-darwin.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
version: 1

before:
hooks:
# - go mod tidy

builds:
- goos:
- darwin
goarch:
- amd64
- arm64
env:
- CGO_ENABLED=1

archives:
- format: tar.gz
# this name template makes the OS and Arch compatible with the results of `uname`.
name_template: >-
{{ .ProjectName }}_
{{- title .Os }}_
{{- if eq .Arch "amd64" }}x86_64
{{- else if eq .Arch "386" }}i386
{{- else }}{{ .Arch }}{{ end }}
{{- if .Arm }}v{{ .Arm }}{{ end }}
34 changes: 34 additions & 0 deletions ci/.goreleaser-linux.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
version: 1

before:
hooks:
# - go mod tidy

builds:
- goos:
- linux
goarch:
- amd64
- arm64
env:
- CGO_ENABLED=1
overrides:
- goos: linux
goarch: arm64
env:
- CC=aarch64-linux-gnu-gcc
- goos: linux
goarch: amd64
env:
- CC=gcc

archives:
- format: tar.gz
# this name template makes the OS and Arch compatible with the results of `uname`.
name_template: >-
{{ .ProjectName }}_
{{- title .Os }}_
{{- if eq .Arch "amd64" }}x86_64
{{- else if eq .Arch "386" }}i386
{{- else }}{{ .Arch }}{{ end }}
{{- if .Arm }}v{{ .Arm }}{{ end }}
31 changes: 31 additions & 0 deletions ci/.goreleaser-windows.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
version: 1

before:
hooks:
# - go mod tidy

builds:
- goos:
- windows
goarch:
- amd64
env:
- CGO_ENABLED=0
# - CGO_LDFLAGS=-L=D:\\a\\_temp\\msys64\\mingw64\\bin
# - CC=D:\a\_temp\msys64\mingw64\bin\x86_64-w64-mingw32-gcc
# - CXX=D:\a\_temp\msys64\mingw64\bin\x86_64-w64-mingw32-g++
flags:
- -x
- -v
- -tags=gowaku_no_rln

archives:
- format: zip
# this name template makes the OS and Arch compatible with the results of `uname`.
name_template: >-
{{ .ProjectName }}_
{{- title .Os }}_
{{- if eq .Arch "amd64" }}x86_64
{{- else if eq .Arch "386" }}i386
{{- else }}{{ .Arch }}{{ end }}
{{- if .Arm }}v{{ .Arm }}{{ end }}
10 changes: 10 additions & 0 deletions ci/.goreleaser.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
version: 1

builds:
- skip: true

release:
draft: true
mode: append
extra_files:
- glob: ./ls2sp-build/**/*

0 comments on commit e4fcdb5

Please sign in to comment.