Merge pull request #438 from bruin-data/sql-escaping #216
Workflow file for this run
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: Release | |
on: | |
push: | |
tags: | |
- '*' | |
permissions: | |
contents: write | |
env: | |
REGISTRY: ghcr.io | |
IMAGE_NAME: bruin-data/bruin | |
jobs: | |
integration-tests: | |
strategy: | |
matrix: | |
platform: [ ubuntu-24.04, ubuntu-22.04, macos-latest, macos-14, windows-2022 ] | |
runs-on: ${{ matrix.platform }} | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
# TODO: Replace with actions/setup-go once issue is resolved https://github.com/actions/setup-go/pull/515 | |
- name: Setup Go | |
uses: antontroshin/setup-go@windows-go-mod-cache | |
with: | |
go-version-file: 'go.mod' | |
cache-dependency-path: "go.sum" | |
- run: make test | |
- name: Install winget | |
if: matrix.platform == 'windows-2022' | |
uses: Cyberboss/install-winget@v1 | |
- run: make integration-test | |
shell: bash | |
prepare-darwin: | |
runs-on: ubuntu-latest | |
needs: integration-tests | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
- name: Workaround Git Security Warning | |
run: | | |
# Workaround a bug in github actions: | |
git config --global --add safe.directory "$GITHUB_WORKSPACE" | |
- uses: actions/setup-go@v4 | |
with: | |
go-version-file: 'go.mod' | |
cache-dependency-path: "go.sum" | |
- shell: bash | |
run: echo "sha_short=$(git rev-parse --short HEAD)" >> $GITHUB_ENV | |
- name: cache darwin | |
uses: actions/cache@v3 | |
with: | |
path: dist/darwin | |
key: darwin-${{ env.sha_short }} | |
- name: Run GoReleaser | |
if: steps.cache.outputs.cache-hit != 'true' | |
run: | | |
docker run --privileged -v /var/run/docker.sock:/var/run/docker.sock -e GGOOS=darwin -e GORELEASER_KEY=${{ secrets.GORELEASER_KEY }} -e COMMIT_SHA=${{ github.sha }} -e VERSION=${{ github.ref_name }} -e GITHUB_TOKEN=${{ secrets.RELEASE_TOKEN }} -e TELEMETRY_KEY=${{ secrets.TELEMETRY_KEY }} -v $(pwd):/src -w /src ghcr.io/bruin-data/goreleaser-cross-pro:v1.22 release --clean --split --verbose | |
prepare-linux: | |
runs-on: ubuntu-latest | |
needs: integration-tests | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
- name: Workaround Git Security Warning | |
run: | | |
# Workaround a bug in github actions: | |
git config --global --add safe.directory "$GITHUB_WORKSPACE" | |
- uses: actions/setup-go@v4 | |
with: | |
go-version-file: 'go.mod' | |
cache-dependency-path: "go.sum" | |
- shell: bash | |
run: echo "sha_short=$(git rev-parse --short HEAD)" >> $GITHUB_ENV | |
- name: cache linux | |
uses: actions/cache@v3 | |
with: | |
path: dist/linux | |
key: linux-${{ env.sha_short }} | |
- name: Run GoReleaser | |
if: steps.cache.outputs.cache-hit != 'true' | |
run: | | |
docker run --privileged -v /var/run/docker.sock:/var/run/docker.sock -e GGOOS=linux -e GORELEASER_KEY=${{ secrets.GORELEASER_KEY }} -e COMMIT_SHA=${{ github.sha }} -e VERSION=${{ github.ref_name }} -e GITHUB_TOKEN=${{ secrets.RELEASE_TOKEN }} -e TELEMETRY_KEY=${{ secrets.TELEMETRY_KEY }} -v $(pwd):/src -w /src ghcr.io/bruin-data/goreleaser-cross-pro:v1.22 release --clean --split --verbose | |
release-unix: | |
runs-on: ubuntu-latest | |
needs: [prepare-linux, prepare-darwin] | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
- name: Workaround Git Security Warning | |
run: | | |
# Workaround a bug in github actions: | |
git config --global --add safe.directory "$GITHUB_WORKSPACE" | |
- shell: bash | |
run: echo "sha_short=$(git rev-parse --short HEAD)" >> $GITHUB_ENV | |
- uses: actions/cache@v3 | |
with: | |
path: dist/linux | |
key: linux-${{ env.sha_short }} | |
- uses: actions/cache@v3 | |
with: | |
path: dist/darwin | |
key: darwin-${{ env.sha_short }} | |
- uses: goreleaser/goreleaser-action@v3 | |
with: | |
distribution: goreleaser-pro | |
version: v2.3.2 | |
args: continue --merge | |
env: | |
GITHUB_TOKEN: ${{ secrets.RELEASE_TOKEN }} | |
GORELEASER_KEY: ${{ secrets.GORELEASER_KEY }} | |
TELEMETRY_KEY: ${{ secrets.TELEMETRY_KEY }} | |
release-windows: | |
runs-on: windows-latest | |
needs: [prepare-linux, prepare-darwin] | |
defaults: | |
run: | |
shell: msys2 {0} | |
steps: | |
- uses: actions/checkout@v3 | |
- uses: msys2/setup-msys2@v2 | |
with: | |
msystem: UCRT64 | |
update: true | |
install: git mingw-w64-ucrt-x86_64-gcc | |
# TODO: Replace with actions/setup-go once issue is resolved https://github.com/actions/setup-go/pull/515 | |
- name: Setup Go | |
uses: antontroshin/setup-go@windows-go-mod-cache | |
with: | |
go-version-file: 'go.mod' | |
cache-dependency-path: "go.sum" | |
- name: Release | |
uses: goreleaser/goreleaser-action@v6 | |
with: | |
version: v2.3.2 | |
distribution: goreleaser-pro | |
args: release --clean --split | |
env: | |
GITHUB_TOKEN: ${{ secrets.RELEASE_TOKEN }} | |
GORELEASER_KEY: ${{ secrets.GORELEASER_KEY }} | |
VERSION: ${{ github.ref_name }} | |
COMMIT_SHA: ${{ github.sha }} | |
TELEMETRY_KEY: ${{ secrets.TELEMETRY_KEY }} | |
GGOOS: windows | |
- name: Upload binaries to release | |
uses: svenstaro/upload-release-action@v2 | |
with: | |
repo_token: ${{ secrets.GITHUB_TOKEN }} | |
file: dist/windows/bruin_Windows_x86_64.zip | |
asset_name: bruin_Windows_x86_64.zip | |
tag: ${{ github.ref }} | |
overwrite: false | |
make_latest: false | |
prerelease: false | |
dockerBuild: | |
runs-on: ubuntu-latest | |
name: Docker Build | |
needs: [release-windows, release-unix] | |
permissions: | |
contents: read | |
packages: write | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Log in to the Container registry | |
uses: docker/login-action@v3 | |
with: | |
registry: ${{ env.REGISTRY }} | |
username: bruin-data | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Extract metadata (tags, labels) for Docker | |
id: meta | |
uses: docker/metadata-action@v5 | |
with: | |
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Build and push Docker image | |
uses: docker/build-push-action@v5 | |
with: | |
context: . | |
platforms: linux/amd64,linux/arm64 | |
push: true | |
tags: ${{ steps.meta.outputs.tags }} | |
labels: ${{ steps.meta.outputs.labels }} | |
cache-from: type=gha | |
cache-to: type=gha,mode=max | |
build-args: | | |
VERSION=${{ github.ref_name }} | |
install-windows: | |
runs-on: windows-latest | |
name: Installer Script on Windows | |
needs: [release-windows, release-unix] | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Use install script | |
shell: bash | |
run: curl -LsSf https://raw.githubusercontent.com/bruin-data/bruin/refs/heads/main/install.sh | sh -s -- -d ${GITHUB_REF##*/} | |
- name: Install winget | |
uses: Cyberboss/install-winget@v1 | |
- name: Test Pipeline | |
shell: bash | |
run: /c/Users/runneradmin/.local/bin/bruin.exe init chess test-pipeline && cd test-pipeline && git init && /c/Users/runneradmin/.local/bin/bruin.exe run . | |
install-unix: | |
runs-on: ubuntu-latest | |
name: Installer Script on Linux | |
needs: [release-windows, release-unix] | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
- name: Extract tag from ref | |
id: extract_tag | |
run: | | |
ref_name="${GITHUB_REF##*/}" | |
echo "tag=${ref_name}" >> $GITHUB_ENV | |
- name: Use install script | |
run: curl -LsSf https://raw.githubusercontent.com/bruin-data/bruin/refs/heads/main/install.sh | sh -s -- -d ${{ env.tag }} | |
- name: Test Pipeline | |
run: bruin init chess test-pipeline && cd test-pipeline && git init && bruin run . | |
release: | |
runs-on: ubuntu-latest | |
needs: [install-unix, install-windows, dockerBuild] | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Extract tag from ref | |
id: extract_tag | |
run: | | |
ref_name="${GITHUB_REF##*/}" | |
echo "tag=${ref_name}" >> $GITHUB_ENV | |
- name: Release promote to latest | |
uses: softprops/action-gh-release@v2 | |
if: startsWith(github.ref, 'refs/tags/') | |
with: | |
token: ${{ secrets.GITHUB_TOKEN }} | |
tag_name: ${{ env.tag }} | |
prerelease: false | |
make_latest: true | |
clear_attachments: false |