Build & Release #232
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Build & Release | |
on: | |
workflow_dispatch: | |
inputs: | |
build_only: | |
description: 'build_only: "true" or empty' | |
required: false | |
repository_dispatch: | |
types: [build-release] | |
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}} | |
PLAUSIBLE_URL: ${{ secrets.PLAUSIBLE_URL }} | |
SENTRY_DSN: ${{ secrets.SENTRY_DSN }} | |
GOPRIVATE: github.com/slingdata-io/* | |
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }} | |
jobs: | |
build: | |
runs-on: [self-hosted, linux, ubuntu-20] | |
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.21" | |
cache: false | |
- 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/sling-cli/${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.test.sh $VERSION | |
sudo rm -rf $WORK_FOLDER/sling | |
echo $VERSION | |
VERSION=$(/__/bin/sling --version | sed 's/Version: //') | |
echo ::set-output name=version::$VERSION | |
release-python: | |
needs: [ release-linux-amd64, release-brew, release-scoop ] | |
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 | |
defaults: | |
run: | |
working-directory: /tmp | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v1 | |
with: | |
fetch-depth: 0 | |
- name: Set up Go | |
uses: actions/setup-go@v3 | |
with: | |
go-version: "1.21" | |
cache: false | |
- name: Configure private token | |
run: | | |
git config --global url."https://${GITHUB_TOKEN}:x-oauth-basic@github.com/".insteadOf "https://github.com/" | |
- 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.21" | |
cache: true | |
- name: Configure Pagefile | |
uses: al-cheb/configure-pagefile-action@v1.2 | |
with: | |
minimum-size: 16GB | |
maximum-size: 16GB | |
disk-root: "C:" | |
- name: Configure private token | |
run: | | |
$url = ("https://" + $env:GITHUB_TOKEN + ":x-oauth-basic@github.com/") | |
git config --global url."$url".insteadOf "https://github.com/" | |
- name: Run GoReleaser | |
uses: goreleaser/goreleaser-action@v3 | |
with: | |
distribution: goreleaser | |
version: latest | |
args: release --clean --skip=validate -f .goreleaser.windows.yaml | |
release-linux-arm64: | |
runs-on: [self-hosted, Linux, ARM64] | |
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.21" | |
cache: false | |
- name: Login docker | |
run: | | |
echo "$DOCKER_PASSWORD" | docker login -u slingdata --password-stdin | |
- name: Configure private token | |
run: | | |
git config --global url."https://${GITHUB_TOKEN}:x-oauth-basic@github.com/".insteadOf "https://github.com/" | |
- name: Run GoReleaser | |
uses: goreleaser/goreleaser-action@v3 | |
with: | |
distribution: goreleaser | |
version: latest | |
args: release --clean --skip=validate -f .goreleaser.linux.arm64.yaml | |
# pushing to docker manually | |
# could not figure out how to make arm64 work in goreleaser | |
- name: Push to Docker Manually | |
run: | | |
rm -f sling && cp dist/sling_linux_arm64/sling . | |
export SLING_VERSION=$( ./sling --version | sed 's/Version: //') | |
docker build -f cmd/sling/Dockerfile.arm64 -t slingdata/sling:$SLING_VERSION-arm64 . | |
docker tag slingdata/sling:$SLING_VERSION-arm64 slingdata/sling:latest-arm64 | |
docker push slingdata/sling:$SLING_VERSION-arm64 | |
docker push slingdata/sling:latest-arm64 | |
release-linux-amd64: | |
# runs-on: ubuntu-20.04 | |
runs-on: [self-hosted, Linux, X64, ubuntu-16] | |
needs: [ release-linux-arm64 ] # for multi-platform docker image | |
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.21" | |
cache: false | |
- name: Login docker | |
run: | | |
echo "$DOCKER_PASSWORD" | docker login -u slingdata --password-stdin | |
- name: Configure private token | |
run: | | |
git config --global url."https://${GITHUB_TOKEN}:x-oauth-basic@github.com/".insteadOf "https://github.com/" | |
- name: Run GoReleaser | |
uses: goreleaser/goreleaser-action@v3 | |
with: | |
distribution: goreleaser | |
version: latest | |
args: release --clean --skip=validate -f .goreleaser.linux.amd64.yaml | |
- name: Dispatch test-sling-action | |
uses: peter-evans/repository-dispatch@v2 | |
with: | |
event-type: test-sling-action |