Skip to content

feat!: implement invoice bysquare & refactor project structure (#106) #122

feat!: implement invoice bysquare & refactor project structure (#106)

feat!: implement invoice bysquare & refactor project structure (#106) #122

Workflow file for this run

name: Release Please
on:
push:
branches:
- master
paths:
- "typescript/**"
- "go/**"
- ".github/.release-manifest.json"
- ".github/.release-config.json"
workflow_dispatch:
inputs:
typescript_release:
description: "Publish TypeScript package"
type: boolean
default: false
typescript_tag:
description: "TypeScript tag name (e.g., typescript/v3.0.0)"
type: string
required: false
go_release:
description: "Build and upload Go artifacts"
type: boolean
default: false
go_tag:
description: "Go tag name (e.g., go/v0.1.0)"
type: string
required: false
permissions:
contents: write
pull-requests: write
jobs:
release-please:
name: Release Please
runs-on: ubuntu-latest
outputs:
typescript_release_created: ${{ steps.release.outputs['typescript--release_created'] }}
typescript_tag_name: ${{ steps.release.outputs['typescript--tag_name'] }}
go_release_created: ${{ steps.release.outputs['go--release_created'] }}
go_tag_name: ${{ steps.release.outputs['go--tag_name'] }}
steps:
- uses: googleapis/release-please-action@v4
id: release
with:
manifest-file: .github/.release-manifest.json
config-file: .github/.release-config.json
token: ${{ secrets.RELEASE_PLEASE_TOKEN }}
typescript-publish:
name: Publish TypeScript Package
needs: release-please
if: ${{ (github.event_name == 'push' && needs.release-please.outputs.typescript_release_created) || (github.event_name == 'workflow_dispatch' && inputs.typescript_release == true) }}
runs-on: ubuntu-latest
permissions:
contents: read
id-token: write
steps:
- uses: actions/checkout@v6
- uses: actions/setup-node@v6
with:
cache: npm
cache-dependency-path: typescript/package-lock.json
node-version: 24
registry-url: "https://registry.npmjs.org"
- name: Build and publish
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
working-directory: typescript
run: |
npm install
node --run build
npm publish --provenance --access public
go-build:
name: Build Go Artifacts
needs: release-please
if: ${{ (github.event_name == 'push' && needs.release-please.outputs.go_release_created) || (github.event_name == 'workflow_dispatch' && inputs.go_release == true) }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
include:
- os: ubuntu-latest
goos: linux
goarch: amd64
- os: ubuntu-latest
goos: linux
goarch: arm64
- os: macos-latest
goos: darwin
goarch: amd64
- os: macos-latest
goos: darwin
goarch: arm64
- os: windows-latest
goos: windows
goarch: amd64
- os: windows-latest
goos: windows
goarch: arm64
steps:
- uses: actions/checkout@v6
- uses: actions/setup-go@v6
with:
go-version: "stable"
cache-dependency-path: go/go.sum
- name: Install cross-compilation tools
if: matrix.goos == 'linux' && matrix.goarch == 'arm64'
run: |
sudo apt-get update
sudo apt-get install -y gcc-aarch64-linux-gnu
- name: Build CLI
shell: bash
working-directory: ./go
env:
VERSION: ${{ needs.release-please.outputs.go_tag_name || inputs.go_tag }}
run: |
VERSION_NUM=${VERSION#go/v}
mkdir -p ../artifacts
CGO_ENABLED=0 GOOS=${{ matrix.goos }} GOARCH=${{ matrix.goarch }} go build \
-ldflags="-s -w -X main.version=${VERSION_NUM}" \
-o ../artifacts/bysquare-${{ matrix.goos }}-${{ matrix.goarch }}${{ matrix.goos == 'windows' && '.exe' || '' }} \
./cmd/bysquare
# Skip Windows ARM64 FFI build due to cross-compilation CGO assembler incompatibility
# The required Windows ARM64 toolchain is not available on GitHub runners
- name: Build FFI
if: ${{ !(matrix.goos == 'windows' && matrix.goarch == 'arm64') }}
shell: bash
working-directory: ./go
env:
VERSION: ${{ needs.release-please.outputs.go_tag_name || inputs.go_tag }}
CC: ${{ matrix.goos == 'linux' && matrix.goarch == 'arm64' && 'aarch64-linux-gnu-gcc' || '' }}
run: |
VERSION_NUM=${VERSION#go/v}
EXT=""
if [ "${{ matrix.goos }}" = "windows" ]; then
EXT=".dll"
elif [ "${{ matrix.goos }}" = "darwin" ]; then
EXT=".dylib"
else
EXT=".so"
fi
CGO_ENABLED=1 GOOS=${{ matrix.goos }} GOARCH=${{ matrix.goarch }} go build \
-buildmode=c-shared \
-ldflags="-X main.version=${VERSION_NUM}" \
-o ../artifacts/libbysquare-${{ matrix.goos }}-${{ matrix.goarch }}${EXT} \
./cmd/libbysquare
cd ../artifacts
ls -la
- name: Install nfpm
if: matrix.goos == 'linux'
shell: bash
run: go install github.com/goreleaser/nfpm/v2/cmd/nfpm@latest
- name: Create packages
if: matrix.goos == 'linux'
shell: bash
env:
VERSION: ${{ needs.release-please.outputs.go_tag_name || inputs.go_tag }}
GOARCH: ${{ matrix.goarch }}
run: |
VERSION_NUM=${VERSION#go/v}
cat > nfpm.yaml << EOF
name: bysquare
arch: ${GOARCH}
platform: linux
version: ${VERSION_NUM}
section: utils
priority: optional
maintainer: Filip Seman <filip.seman@pm.me>
description: |
A CLI tool for generating and parsing PAY by square QR codes,
a national standard for QR code payments adopted by the Slovak
Banking Association in 2013.
homepage: https://github.com/xseman/bysquare
license: Apache-2.0
contents:
- src: artifacts/bysquare-linux-${GOARCH}
dst: /usr/bin/bysquare
file_info:
mode: 0755
- src: LICENSE
dst: /usr/share/doc/bysquare/LICENSE
file_info:
mode: 0644
EOF
nfpm package --packager deb --target artifacts/
nfpm package --packager rpm --target artifacts/
- uses: actions/upload-artifact@v6
with:
name: bysquare-${{ matrix.goos }}-${{ matrix.goarch }}
path: artifacts/*
retention-days: 1
go-upload:
name: Upload Go Release Assets
needs: [release-please, go-build]
if: ${{ (github.event_name == 'push' && needs.release-please.outputs.go_release_created) || (github.event_name == 'workflow_dispatch' && inputs.go_release == true) }}
runs-on: ubuntu-latest
steps:
- uses: actions/download-artifact@v7
with:
pattern: bysquare-*
path: artifacts
merge-multiple: true
- name: Generate checksums
working-directory: artifacts
run: |
sha256sum * > CHECKSUMS.txt
- name: Upload artifacts to release
env:
GH_TOKEN: ${{ github.token }}
GH_REPO: ${{ github.repository }}
run: |
gh release upload \
${{ github.event_name == 'push' && needs.release-please.outputs.go_tag_name || inputs.go_tag }} \
artifacts/* \
--clobber