Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Enable push event for master branch in tagpr workflow (#749) #1910

Enable push event for master branch in tagpr workflow (#749)

Enable push event for master branch in tagpr workflow (#749) #1910

Workflow file for this run

name: sqldef
on:
push:
branches:
- master
tags:
- v*
pull_request:
types:
- opened
- synchronize
- reopened
jobs:
test:
runs-on: ubuntu-22.04
strategy:
matrix:
target:
- sqlite3def
- mssqldef
include:
- target: mysqldef
mysql_flavor: mysql
mysql_version: '5.7'
- target: mysqldef
mysql_flavor: mysql
mysql_version: '8.0'
- target: mysqldef
mysql_flavor: mariadb
mariadb_version: '11.8'
- target: psqldef
postgres_version: 12
- target: psqldef
postgres_version: 13
- target: psqldef
postgres_version: 14
- target: psqldef
postgres_version: 15
- target: psqldef
postgres_version: 16
- target: psqldef
postgres_version: 17
fail-fast: false
steps:
- uses: actions/setup-go@v5
with:
go-version: 1.21
- uses: actions/checkout@v5
- run: docker compose up -d
env:
MYSQL_VERSION: ${{ matrix.mysql_version }}
MARIADB_VERSION: ${{ matrix.mariadb_version }}
POSTGRES_VERSION: ${{ matrix.postgres_version }}
- run: make deps
- run: echo "GODEBUG=tlsrsakex=1" >> $GITHUB_ENV
if: matrix.mysql_version == '5.7'
- run: echo "MYSQL_FLAVOR=${{ matrix.mysql_flavor }}" >> $GITHUB_ENV
if: matrix.mysql_flavor
- run: echo "MYSQL_PORT=3307" >> $GITHUB_ENV
if: matrix.mysql_flavor == 'mariadb'
- run: make test-${{ matrix.target }}
test-result:
if: ${{ always() }}
runs-on: ubuntu-22.04
needs: [test]
steps:
- name: test jobs have failed
run: exit 1
working-directory:
if: ${{ contains(needs.*.result, 'failure') || contains(needs.*.result, 'cancelled') }}
package:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
include:
- { GOOS: linux, GOARCH: amd64, EXT: tar.gz }
- { GOOS: linux, GOARCH: '386', EXT: tar.gz }
- { GOOS: linux, GOARCH: arm64, EXT: tar.gz }
- { GOOS: linux, GOARCH: arm, EXT: tar.gz }
- { GOOS: windows, GOARCH: amd64, EXT: zip }
steps:
- uses: actions/setup-go@v5
with:
go-version: 1.21
- uses: actions/checkout@v5
- name: make package-${{ matrix.EXT }}
run: |
make package-${{ matrix.EXT }} GOOS=${{ matrix.GOOS }} GOARCH=${{ matrix.GOARCH }}
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: sqldef-${{ matrix.GOOS }}-${{ matrix.GOARCH }}
path: package/*def_${{ matrix.GOOS }}_${{ matrix.GOARCH }}.${{ matrix.EXT }}
package-macos:
runs-on: macos-latest
strategy:
matrix:
include:
- { GOOS: darwin, GOARCH: amd64, EXT: zip }
- { GOOS: darwin, GOARCH: arm64, EXT: zip }
fail-fast: false
steps:
- uses: actions/setup-go@v5
with:
go-version: 1.21
- uses: actions/checkout@v5
- name: make package-${{ matrix.EXT }}
run: make package-${{ matrix.EXT }} GOOS=${{ matrix.GOOS }} GOARCH=${{ matrix.GOARCH }}
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: sqldef-${{ matrix.GOOS }}-${{ matrix.GOARCH }}
path: package/*def_${{ matrix.GOOS }}_${{ matrix.GOARCH }}.${{ matrix.EXT }}
release:
runs-on: ubuntu-latest
needs:
- test
- package
- package-macos
if: startsWith(github.ref, 'refs/tags/')
steps:
- uses: actions/checkout@v5
- { uses: actions/download-artifact@v4, with: { name: sqldef-linux-amd64, path: package/ } }
- { uses: actions/download-artifact@v4, with: { name: sqldef-linux-386, path: package/ } }
- { uses: actions/download-artifact@v4, with: { name: sqldef-linux-arm64, path: package/ } }
- { uses: actions/download-artifact@v4, with: { name: sqldef-linux-arm, path: package/ } }
- { uses: actions/download-artifact@v4, with: { name: sqldef-darwin-amd64, path: package/ } }
- { uses: actions/download-artifact@v4, with: { name: sqldef-darwin-arm64, path: package/ } }
- { uses: actions/download-artifact@v4, with: { name: sqldef-windows-amd64, path: package/ } }
- name: Release binaries
run: |
export VERSION=$(echo "$GITHUB_REF" | sed -e 's!refs/tags/!!')
curl -L "https://github.com/tcnksm/ghr/releases/download/${GHR_VERSION}/ghr_${GHR_VERSION}_linux_amd64.tar.gz" | tar xvz
"ghr_${GHR_VERSION}_linux_amd64/ghr" -u sqldef -r sqldef -replace -n "$VERSION" "$VERSION" package/
env:
GHR_VERSION: v0.13.0
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- uses: actions/checkout@v5
with:
repository: sqldef/homebrew-sqldef
ssh-key: ${{ secrets.HOMEBREW_DEPLOY_KEY }}
path: ./homebrew-sqldef
- name: Update homebrew
run: |
set -x
cd ./homebrew-sqldef
VERSION=$(echo "$GITHUB_REF" | sed -e 's!refs/tags/!!')
sed -i -e "s/tag: '.*'/tag: '$VERSION'/" mysqldef.rb psqldef.rb mssqldef.rb sqlite3def.rb
git add .
if ! git diff-index --quiet HEAD --; then
git config --global user.email "[email protected]"
git config --global user.name "sqldef"
git commit -m "Version $VERSION"
git push origin master
fi