Skip to content

Commit

Permalink
fix(cli): release workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
danielebriggi committed Jun 18, 2024
1 parent d3841ae commit 3d30564
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 13 deletions.
19 changes: 11 additions & 8 deletions .github/workflows/release-cli.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Create an incremental tag (like `cli-v1.2.0`) on Github using SemVer https://semver.org: x.y.z
# Create the Release (like `cli-v1.2.0`) based on this tag and with the same name.
# Build the CLI for all OS and upload them as assets to the release.
# Create the Release (like `cli-v1.2.0`) related to the tag and with the same name.
# Build the CLI for all OS and upload them to the release as assets.

name: Release CLI

Expand All @@ -17,7 +17,7 @@ on:

jobs:
release-cli:
if: ${{ github.ref == 'refs/heads/main' }}
# if: ${{ github.ref == 'refs/heads/main' }}
name: Release CLI
strategy:
matrix:
Expand All @@ -43,21 +43,24 @@ jobs:
steps:
- name: Checkout code
uses: actions/checkout@v3
with:
# download tags
fetch-depth: 0

- name: Set env var
run: echo "ZIPFILE=sqlitecloud-go-${{ steps.tag-and-release.outputs.name }}-${{ env.OSNAME }}-${{ env.ARCHNAME }}.zip" >> $GITHUB_ENV

- name: Build CLI
run: |
cd GO/cli
cd cli
go build -o ../sqlc
cd ..
zip ${{ env.ZIPFILE }} sqlc
- name: Last version
id: last-version
# last tag that starts with 'cli-v', eg: cli-v1.2.0 but outputs it as: v1.2.0
run: echo "::set-output name=number::$(git tag --list 'cli-v*' | sort -V | tail -n1 | sed 's/cli-//')"
# last tag that starts with 'cli-v', eg: cli-v1.2.0 but outputs it as: 1.2.0
run: echo "::set-output name=number::$(git tag --list 'cli-v*' | sort -V | tail -n1 | sed 's/cli-v//')"

- name: Bump version
id: bump-version
Expand Down Expand Up @@ -91,7 +94,7 @@ jobs:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.release.outputs.upload_url }}
asset_path: ./GO/${{ env.ZIPFILE }}
asset_path: ./${{ env.ZIPFILE }}
asset_name: ${{ env.ZIPFILE }}
asset_content_type: application/zip

Expand All @@ -100,5 +103,5 @@ jobs:
if: matrix.goos == 'darwin'
with:
name: ${{ env.ZIPFILE }}
path: ./GO/${{ env.ZIPFILE }}
path: ./${{ env.ZIPFILE }}
if-no-files-found: error
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# A tag is a release version on pkg.go.dev, which is
# notified with the publishing go command.

name: Release
name: Release SDK

on:
workflow_dispatch:
Expand All @@ -16,30 +16,35 @@ on:
- major

jobs:
release:
release-sdk:
if: ${{ github.ref == 'refs/heads/main' }}
runs-on: ubuntu-latest
name: Tag for release
steps:
- name: Checkout code
uses: actions/checkout@v2
uses: actions/checkout@v3
with:
# download tags
fetch-depth: 0

- name: Last version
id: last-version
# last tag that starts with 'v', eg: v1.0.3
run: echo "::set-output name=tag::$(git tag --list 'v*' | sort -V | tail -n1)"
# last tag that starts with 'v', eg: v1.0.3 but outputs it as: 1.0.3
run: echo "::set-output name=tag::$(git tag --list 'v*' | sort -V | tail -n1 | sed 's/v//')"

- name: Bump version
id: bump-version
uses: olegsu/semver-action@v1
with:
version: ${{ steps.last-version.outputs.tag }}
bump: ${{ inputs.choice }}

- name: Create tag as version for the package
run: |
git config --global user.email "github-actions[bot]@users.noreply.github.com"
git config --global user.name "GitHub Actions"
git tag v${{ steps.bump-version.outputs.version }}
git push origin v${{ steps.bump-version.outputs.version }}
- name: Publish on pkg.go.dev
run: GOPROXY=proxy.golang.org go list -m github.com/sqlitecloud/sqlitecloud-go@v${{ steps.bump-version.outputs.version }}

0 comments on commit 3d30564

Please sign in to comment.