Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
69 changes: 68 additions & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ jobs:
- os: darwin
runs-on: macos-latest
arch: arm64
- os: darwin
runs-on: macos-latest
arch: x86_64
- os: linux
runs-on: ubuntu-latest
arch: x86_64
Expand Down Expand Up @@ -149,6 +152,71 @@ jobs:
name: sqlrsync-${{ matrix.os }}-${{ matrix.arch }}
path: release/*

auto-tag:
if: github.ref == 'refs/heads/main' && github.event_name == 'push'
runs-on: ubuntu-latest
outputs:
version: ${{ steps.extract-version.outputs.version }}
tag-created: ${{ steps.tag-check.outputs.tag-created }}
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Extract version from main.go
id: extract-version
run: |
VERSION=$(grep 'var VERSION = ' client/main.go | sed 's/var VERSION = "\(.*\)"/\1/')
echo "version=$VERSION" >> $GITHUB_OUTPUT
echo "Extracted version: $VERSION"

- name: Check if tag exists
id: tag-check
run: |
VERSION=${{ steps.extract-version.outputs.version }}
if git rev-parse "v$VERSION" >/dev/null 2>&1; then
echo "Tag v$VERSION already exists"
echo "tag-created=false" >> $GITHUB_OUTPUT
else
echo "Tag v$VERSION does not exist, will create"
echo "tag-created=true" >> $GITHUB_OUTPUT
fi

- name: Create and push tag
if: steps.tag-check.outputs.tag-created == 'true'
run: |
VERSION=${{ steps.extract-version.outputs.version }}
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git tag -a "v$VERSION" -m "Release v$VERSION"
git push origin "v$VERSION"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

create-release:
if: needs.auto-tag.outputs.tag-created == 'true'
needs: [build, auto-tag]
runs-on: ubuntu-latest
steps:
- name: Download all artifacts
uses: actions/download-artifact@v4

- name: Create GitHub Release
uses: softprops/action-gh-release@v1
with:
tag_name: v${{ needs.auto-tag.outputs.version }}
name: Release v${{ needs.auto-tag.outputs.version }}
draft: false
prerelease: false
files: |
sqlrsync-linux-x86_64/sqlrsync-linux-x86_64
sqlrsync-darwin-amd64/sqlrsync-darwin-amd64
sqlrsync-darwin-arm64/sqlrsync-darwin-arm64
generate_release_notes: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

release:
if: github.event_name == 'release'
needs: build
Expand All @@ -164,6 +232,5 @@ jobs:
sqlrsync-linux-x86_64/sqlrsync-linux-x86_64
sqlrsync-darwin-amd64/sqlrsync-darwin-amd64
sqlrsync-darwin-arm64/sqlrsync-darwin-arm64
sqlrsync-windows-amd64/sqlrsync-windows-amd64.exe
env:
GITHUB_TOKEN: ${{ secrets.AUTH_TOKEN_GITHUB }}
Loading