Skip to content

Build & Release

Build & Release #144

Workflow file for this run

name: Build & Release
on:
workflow_dispatch:
inputs:
build_only:
description: 'build_only: "true" or empty'
required: false
env:
GITHUB_TOKEN: ${{ secrets.REPO_ACCESS_TOKEN }}
AWS_ACCESS_KEY_ID: ${{ secrets.DO_SPACE_ACCESS_KEY}}
AWS_SECRET_ACCESS_KEY: ${{ secrets.DO_SPACE_SECRET_KEY}}
RUDDERSTACK_KEY: ${{ secrets.RUDDERSTACK_KEY }}
jobs:
build:
runs-on: [self-hosted, linux]
timeout-minutes: 5
outputs:
VERSION: ${{ steps.get_version.outputs.VERSION }}
steps:
- uses: actions/checkout@v2
- name: Set up GoLang
uses: actions/setup-go@v3
with:
go-version: "1.19"
cache: false
# - uses: actions/cache@v3
# with:
# path: ~/go/pkg/mod
# key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
# restore-keys: |
# ${{ runner.os }}-go-
- name: Get the version
id: get_version
run: |
git pull --ff-only
git tag -l --sort=-creatordate | head -n 9
TAG=$(git tag -l --sort=-creatordate | head -n 1)
VERSION=$(echo $TAG | sed 's/v//')
echo "VERSION -> $VERSION"
echo ::set-output name=VERSION::$VERSION
- id: step1
name: Build
env:
VERSION: ${{ steps.get_version.outputs.VERSION }}
run: |
bash scripts/prep.gomod.sh
export WORK_FOLDER=/__/work/${GITHUB_RUN_NUMBER}
mkdir -p $WORK_FOLDER
cp -r . $WORK_FOLDER/sling
sudo chmod -R 777 $WORK_FOLDER
docker run --rm -v /__/docker-data/devbox/root/go:/root/go -v /__:/__ -v /tmp:/tmp -v $WORK_FOLDER:/work --workdir /work/sling flarco/devbox:base bash scripts/build.linux.sh $VERSION
sudo rm -rf $WORK_FOLDER/sling
echo $VERSION
VERSION=$(/__/bin/sling --version | sed 's/Version: //')
echo ::set-output name=version::$VERSION
release:
if: "! (contains(github.event.inputs.build_only, 'true'))"
needs: [build]
runs-on: ${{ matrix.runner }}
timeout-minutes: 20
strategy:
fail-fast: true
matrix:
# runner: [self-hosted-mac, self-hosted-linux, self-hosted-windows]
runner: [macos-latest, ubuntu-20.04, windows-latest]
# runner: [self-hosted-mac, ubuntu-20.04, windows-latest]
# doesn't work, put double quote at the end
# env:
# VERSION: ${{ needs.build.outputs.version }}"
steps:
- uses: actions/checkout@v3
- name: Dump context
env:
JOB_CONTEXT: ${{ toJson(job) }}
MATRIX_CONTEXT: ${{ toJson(matrix) }}
RUNNER_CONTEXT: ${{ toJson(runner) }}
run: |
echo "JOB_CONTEXT -> $JOB_CONTEXT"
echo "MATRIX_CONTEXT -> $MATRIX_CONTEXT"
echo "RUNNER_CONTEXT -> $RUNNER_CONTEXT"
echo "VERSION -> $VERSION"
- name: Set up GoLang
uses: actions/setup-go@v3
with:
go-version: "1.19"
cache: true
- name: Build Sling (Linux)
env:
VERSION: ${{ needs.build.outputs.VERSION }}
if: runner.os == 'linux'
run: bash scripts/ci/build.linux.sh $VERSION
- name: Build Sling (Mac)
env:
VERSION: ${{ needs.build.outputs.VERSION }}
if: runner.os == 'macOS'
run: bash scripts/ci/build.mac.sh $VERSION
- name: Configure Pagefile (Windows)
if: runner.os == 'windows'
uses: al-cheb/configure-pagefile-action@v1.2
with:
minimum-size: 16GB
maximum-size: 16GB
disk-root: "C:"
- name: Build Sling (Windows)
env:
VERSION: ${{ needs.build.outputs.VERSION }}
if: runner.os == 'windows'
run: .\scripts\ci\build.win.ps1 $env:VERSION
- uses: BetaHuhn/do-spaces-action@v2
with:
access_key: ${{ secrets.DO_SPACE_ACCESS_KEY}}
secret_key: ${{ secrets.DO_SPACE_SECRET_KEY }}
space_name: ${{ secrets.DO_SPACE_NAME }}
space_region: ${{ secrets.DO_SPACE_REGION }}
source: dist
out_dir: slingdata.io/dist
release-python:
needs: [release]
runs-on: ubuntu-latest
steps:
- name: Trigger Upload to PyPi
uses: peter-evans/repository-dispatch@v2
with:
token: ${{ secrets.REPO_ACCESS_TOKEN }}
repository: slingdata-io/sling-python
event-type: release-python
client-payload: '{"ref": "${{ github.ref }}", "sha": "${{ github.sha }}"}'
release-brew:
runs-on: [self-hosted, macOS, ARM64]
timeout-minutes: 20
# runs-on: macos-latest
steps:
- name: Checkout
uses: actions/checkout@v1
with:
fetch-depth: 0
- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: "1.19"
cache: false
- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v3
with:
distribution: goreleaser
version: latest
args: release --clean --skip-validate -f .goreleaser.mac.yaml
release-scoop:
# runs-on: [self-hosted, Windows]
runs-on: windows-latest
timeout-minutes: 20
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: "1.19"
cache: true
- name: Configure Pagefile
uses: al-cheb/configure-pagefile-action@v1.2
with:
minimum-size: 16GB
maximum-size: 16GB
disk-root: "C:"
- name: Run GoReleaser
# uses: flarco/goreleaser-action@master
uses: goreleaser/goreleaser-action@v3
with:
distribution: goreleaser
version: latest
args: release --clean --skip-validate -f .goreleaser.windows.yaml
release-linux:
runs-on: ubuntu-latest
# runs-on: [self-hosted, Linux]
timeout-minutes: 20
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: "1.19"
cache: true
- name: Login docker
env:
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
run: |
echo "$DOCKER_PASSWORD" | docker login -u slingdata --password-stdin
- name: Run GoReleaser
# uses: flarco/goreleaser-action@master
uses: goreleaser/goreleaser-action@v3
with:
distribution: goreleaser
version: latest
args: release --clean --skip-validate -f .goreleaser.linux.yaml