135 lines
4.7 KiB
YAML
135 lines
4.7 KiB
YAML
on:
|
|
release:
|
|
types:
|
|
- published
|
|
pull_request:
|
|
types:
|
|
- opened
|
|
- synchronize
|
|
- reopened
|
|
branches-ignore:
|
|
- "dependabot/**"
|
|
|
|
name: Release (Linux)
|
|
jobs:
|
|
build:
|
|
runs-on: ubuntu-18.04
|
|
strategy:
|
|
matrix:
|
|
include:
|
|
- arch: amd64
|
|
cc: gcc
|
|
|
|
- arch: amd64
|
|
cc: gcc
|
|
static: true
|
|
deploy_test_runner: true
|
|
|
|
- arch: arm64
|
|
cc: aarch64-linux-gnu-gcc
|
|
|
|
- arch: arm64
|
|
cc: aarch64-linux-gnu-gcc
|
|
static: true
|
|
|
|
- arch: arm
|
|
arm: 6
|
|
cc: arm-linux-gnueabi-gcc
|
|
|
|
- arch: arm
|
|
arm: 6
|
|
cc: arm-linux-gnueabi-gcc
|
|
static: true
|
|
|
|
- arch: arm
|
|
arm: 7
|
|
cc: arm-linux-gnueabihf-gcc
|
|
|
|
- arch: arm
|
|
arm: 7
|
|
cc: arm-linux-gnueabihf-gcc
|
|
static: true
|
|
|
|
env:
|
|
GOOS: linux
|
|
GOARCH: ${{ matrix.arch }}
|
|
GOARM: ${{ matrix.arm }}
|
|
CC: ${{ matrix.cc }}
|
|
LDFLAGS: ${{ matrix.static && '-extldflags "-static"' || '' }}
|
|
TAGS: ${{ matrix.static && 'osusergo,netgo,sqlite_omit_load_extension' || '' }}
|
|
SUFFIX: "${{ matrix.static && '-static' || ''}}"
|
|
VERSION: "${{ github.event_name == 'release' && github.event.release.name || github.sha }}"
|
|
|
|
|
|
steps:
|
|
- uses: actions/checkout@v2
|
|
|
|
- uses: actions/setup-go@v2
|
|
with:
|
|
go-version: '1.17'
|
|
|
|
- name: Install cross-compilers
|
|
run: |
|
|
sudo apt-get update
|
|
sudo apt-get install -y gcc-aarch64-linux-gnu gcc-arm-linux-gnueabihf gcc-arm-linux-gnueabi
|
|
|
|
- name: Install nfpm
|
|
run: |
|
|
wget https://github.com/goreleaser/nfpm/releases/download/v2.2.3/nfpm_2.2.3_Linux_x86_64.tar.gz
|
|
tar zxvf nfpm_2.2.3_Linux_x86_64.tar.gz
|
|
|
|
- name: Build litestream
|
|
run: |
|
|
rm -rf dist && mkdir -p dist
|
|
|
|
cp etc/litestream.yml etc/litestream.service dist
|
|
cat etc/nfpm.yml | LITESTREAM_VERSION=${{ env.VERSION }} envsubst > dist/nfpm.yml
|
|
|
|
CGO_ENABLED=1 go build -ldflags "-s -w ${{ env.LDFLAGS }} -X 'main.Version=${{ env.VERSION }}'" -tags "${{ env.TAGS }}" -o dist/litestream ./cmd/litestream
|
|
|
|
cd dist
|
|
tar -czvf litestream-${{ env.VERSION }}-${{ env.GOOS }}-${{ env.GOARCH }}${{ env.GOARM }}${{ env.SUFFIX }}.tar.gz litestream
|
|
../nfpm pkg --config nfpm.yml --packager deb --target litestream-${{ env.VERSION }}-${{ env.GOOS }}-${{ env.GOARCH }}${{ env.GOARM }}${{ env.SUFFIX }}.deb
|
|
|
|
- name: Upload binary artifact
|
|
uses: actions/upload-artifact@v2
|
|
with:
|
|
name: litestream-${{ env.VERSION }}-${{ env.GOOS }}-${{ env.GOARCH }}${{ env.GOARM }}${{ env.SUFFIX }}.tar.gz
|
|
path: dist/litestream-${{ env.VERSION }}-${{ env.GOOS }}-${{ env.GOARCH }}${{ env.GOARM }}${{ env.SUFFIX }}.tar.gz
|
|
if-no-files-found: error
|
|
|
|
- name: Upload debian artifact
|
|
uses: actions/upload-artifact@v2
|
|
with:
|
|
name: litestream-${{ env.VERSION }}-${{ env.GOOS }}-${{ env.GOARCH }}${{ env.GOARM }}${{ env.SUFFIX }}.deb
|
|
path: dist/litestream-${{ env.VERSION }}-${{ env.GOOS }}-${{ env.GOARCH }}${{ env.GOARM }}${{ env.SUFFIX }}.deb
|
|
if-no-files-found: error
|
|
|
|
- name: Upload release tarball
|
|
uses: actions/upload-release-asset@v1.0.2
|
|
if: github.event_name == 'release'
|
|
env:
|
|
GITHUB_TOKEN: ${{ github.token }}
|
|
with:
|
|
upload_url: ${{ steps.release.outputs.upload_url }}
|
|
asset_path: ./dist/litestream-${{ env.VERSION }}-${{ env.GOOS }}-${{ env.GOARCH }}${{ env.GOARM }}${{ env.SUFFIX }}.tar.gz
|
|
asset_name: litestream-${{ env.VERSION }}-${{ env.GOOS }}-${{ env.GOARCH }}${{ env.GOARM }}${{ env.SUFFIX }}.tar.gz
|
|
asset_content_type: application/gzip
|
|
|
|
- name: Upload debian package
|
|
uses: actions/upload-release-asset@v1.0.2
|
|
if: github.event_name == 'release'
|
|
env:
|
|
GITHUB_TOKEN: ${{ github.token }}
|
|
with:
|
|
upload_url: ${{ steps.release.outputs.upload_url }}
|
|
asset_path: ./dist/litestream-${{ env.VERSION }}-${{ env.GOOS }}-${{ env.GOARCH }}${{ env.GOARM }}${{ env.SUFFIX }}.deb
|
|
asset_name: litestream-${{ env.VERSION }}-${{ env.GOOS }}-${{ env.GOARCH }}${{ env.GOARM }}${{ env.SUFFIX }}.deb
|
|
asset_content_type: application/octet-stream
|
|
|
|
- name: Dispatch test runner
|
|
if: matrix.deploy_test_runner && github.actor != 'dependabot'
|
|
run: sleep 60 && gh workflow run deploy.yml -R benbjohnson/litestream-test-runner -f run_id=${{ github.run_id }} -f litestream_version=${{ github.sha }}
|
|
env:
|
|
GITHUB_TOKEN: ${{ secrets.PAT_TOKEN }}
|