Skip to content

Commit

Permalink
Merge pull request #9 from DaredevilOSS/fix-release
Browse files Browse the repository at this point in the history
[release] fix release
  • Loading branch information
SockworkOrange authored Jun 28, 2024
2 parents c5481cc + 7e03063 commit 119e0b2
Show file tree
Hide file tree
Showing 7 changed files with 60 additions and 80 deletions.
117 changes: 48 additions & 69 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ jobs:
with:
dotnet-version: '8.0.x'

- name: install Wasi workload
- name: Install Wasi workload
run: dotnet workload install wasi-experimental

- name: Download Wasi SDK on Ubuntu
Expand All @@ -85,51 +85,13 @@ jobs:
name: wasm-file
path: dist/plugin.wasm

# codegen-tests:
# name: Codegen Test
# runs-on: ubuntu-latest
# needs: [build]
# strategy:
# matrix:
# file-per-query: [ 'true', 'false' ]
# generate-csproj: [ 'true', 'false' ]
# target-framework: [ 'net8.0', 'netstandard2.0', 'netstandard2.1' ]
#
# steps:
# - uses: actions/checkout@v4
# - uses: actions/download-artifact@v4
# with:
# name: wasm-file
# path: dist
#
# - name: Load .env file
# uses: xom9ikk/dotenv@v2.3.0
# with:
# load-mode: strict
#
# - uses: sqlc-dev/setup-sqlc@v4
# with:
# sqlc-version: '1.25.0'
#
# - name: Updating plugin sha
# run: ./scripts/wasm/update_sha.sh ${SQLC_CI_FILE}
#
# - name: Codegen Test
# run: ./scripts/tests/run_codegen.sh ${SQLC_CI_FILE} \
# ${{ matrix.file-per-query }} ${{ matrix.generate-csproj }} ${{ matrix.target-framework }}
#
# - uses: actions/setup-dotnet@v4
# with:
# dotnet-version: ${{ matrix.target-framework == 'net8.0' && '8.0.x' || '3.1.x' }}

end2end-tests:
name: End-to-End Tests
runs-on: ubuntu-latest
needs: [build]

steps:
- uses: actions/checkout@v4

- uses: actions/download-artifact@v4
with:
name: wasm-file
Expand All @@ -146,8 +108,8 @@ jobs:

- name: Verify pushed generated code is synced
run: |
./scripts/wasm/update_sha.sh $SQLC_CI_FILE
sqlc -f $SQLC_CI_FILE diff
./scripts/wasm/update_sha.sh ${SQLC_CI_FILE}
sqlc -f ${SQLC_CI_FILE} diff
- name: Docker compose
uses: hoverkraft-tech/compose-action@v1.5.1
Expand All @@ -159,7 +121,7 @@ jobs:
- name: End-to-End Tests
run: ./scripts/tests/run_end2end.sh

release:
name: Release
runs-on: ubuntu-latest
Expand All @@ -171,41 +133,52 @@ jobs:
with:
fetch-depth: 0

- uses: actions/download-artifact@v2
- uses: actions/download-artifact@v4
with:
name: wasm-file

- name: Bump version and create new tag
id: bump_version
run: |
bump_version() {
latest_tag=$1
latest_commit_msg=$2
BUMP_TYPE="patch" # Initialize the default version bump type to patch
if [[ $latest_commit_msg == *"[major]"* ]]; then
BUMP_TYPE="major"
elif [[ $latest_commit_msg == *"[minor]"* ]]; then
BUMP_TYPE="minor"
fi
case $BUMP_TYPE in
"major")
NEW_TAG=$(echo $latest_tag | awk -F. '{OFS="."; $1="v" substr($1,2)+1; $2="0"; $3="0"; print}')
;;
"minor")
NEW_TAG=$(echo $latest_tag | awk -F. '{OFS="."; $2=$2+1; $3="0"; print}')
;;
"patch")
NEW_TAG=$(echo $latest_tag | awk -F. '{OFS="."; $3=$3+1; print}')
;;
esac
return NEW_TAG
}
set -e
echo "Extract the latest tag version"
LATEST_TAG=$(git describe --tags $(git rev-list --tags --max-count=1))
echo "LATEST_TAG=$LATEST_TAG" >> $GITHUB_ENV
echo "latest tag version: $LATEST_TAG"
LATEST_TAG_COMMIT=$(git rev-list --tags --max-count=1)
LATEST_COMMIT_MSG=$(git log -1 --pretty=%B)
BUMP_TYPE="patch" # Initialize the default version bump type to patch
if [[ $LATEST_COMMIT_MSG == *"[major]"* ]]; then
BUMP_TYPE="major"
elif [[ $LATEST_COMMIT_MSG == *"[minor]"* ]]; then
BUMP_TYPE="minor"
if [ -z $LATEST_TAG_COMMIT ]; then
NEW_TAG="0.10.0" # default 1st release version
else
LATEST_TAG=$(git describe --tags $LATEST_TAG_COMMIT)
echo "latest tag version: $LATEST_TAG"
NEW_TAG=$(bump_version $LATEST_TAG $LATEST_COMMIT_MSG)
fi
# Bump the version based on the type
case $BUMP_TYPE in
"major")
NEW_TAG=$(echo $LATEST_TAG | awk -F. '{OFS="."; $1="v" substr($1,2)+1; $2="0"; $3="0"; print}')
;;
"minor")
NEW_TAG=$(echo $LATEST_TAG | awk -F. '{OFS="."; $2=$2+1; $3="0"; print}')
;;
"patch")
NEW_TAG=$(echo $LATEST_TAG | awk -F. '{OFS="."; $3=$3+1; print}')
;;
esac
echo "New tag version: $NEW_TAG"
echo "NEW_TAG=$NEW_TAG" >> $GITHUB_ENV
Expand All @@ -223,12 +196,18 @@ jobs:
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
set -e
LATEST_TAG=${{ env.LATEST_TAG }}
NEW_TAG=${{ env.NEW_TAG }}
SHA256_HASH=${{ env.SHA256_HASH }}
PREVIOUS_TAG=$(git rev-list -n 1 $LATEST_TAG)
CHANGE_LOG=$(git --no-pager log $PREVIOUS_TAG..HEAD --pretty=format:'%h - %an, %ar : %s')
if [ -z $LATEST_TAG ]; then
CHANGE_LOG="TBD: Manually fill the 1st release features in here"
else
PREVIOUS_TAG=$(git rev-list -n 1 $LATEST_TAG)
CHANGE_LOG=$(git --no-pager log $PREVIOUS_TAG..HEAD --pretty=format:'%h - %an, %ar : %s')
fi
# Define the release notes template
RELEASE_NOTES=$(cat <<EOF
Expand All @@ -248,7 +227,7 @@ jobs:
$CHANGE_LOG
## Contributors
* @doron050 @SockworkOrange
* @SockworkOrange
EOF
)
Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,11 @@ sql:
options:
driver: mysql2
```
### Options Documentation
| Option | Possible values | Optional | Info |
|-----------------|------------------------------------------------|----------|-------------------------------------------------------------------------------------------------------------|
| driver | <br/>values: `MySqlConnector`,`Npgsql` | No | Choosing the driver to use - refer to the [above](#supported-sql-engines) section on supported SQL engines. |
| driver | <br/>values: `mysql2`,`pg` | No | Choosing the driver to use - refer to the [above](#supported-sql-engines) section on supported SQL engines. |
| rubyVersion | default: `3.3`<br/>values: `3.1`, `3.2`, `3.3` | Yes | Determines the Ruby version the generated code should support.. |
| generateGemfile | default: `false`<br/>values: `false`,`true` | Yes | Assists you with the integration of SQLC and Ruby by generating a `Gemfile` with the needed dependencies. |

Expand Down
4 changes: 0 additions & 4 deletions examples/mysql2/Gemfile

This file was deleted.

5 changes: 0 additions & 5 deletions examples/pg/Gemfile

This file was deleted.

4 changes: 4 additions & 0 deletions sqlc.ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ sql:
out: examples/pg
options:
driver: pg
rubyVersion: "3.3"
generateGemfile: false
- schema: "examples/authors/mysql/schema.sql"
queries: "examples/authors/mysql/query.sql"
engine: "mysql"
Expand All @@ -21,3 +23,5 @@ sql:
out: examples/mysql2
options:
driver: mysql2
rubyVersion: "3.3"
generateGemfile: false
6 changes: 5 additions & 1 deletion sqlc.local.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,15 @@ sql:
out: examples/pg
options:
driver: pg
rubyVersion: "3.3"
generateGemfile: false
- schema: "examples/authors/mysql/schema.sql"
queries: "examples/authors/mysql/query.sql"
engine: "mysql"
codegen:
- plugin: ruby
out: examples/mysql2
options:
driver: mysql2
driver: mysql2
rubyVersion: "3.3"
generateGemfile: false
1 change: 1 addition & 0 deletions tests/consts.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@ module Consts

DR_SEUSS_AUTHOR = "Dr. Seuss"
DR_SEUSS_QUOTE = "You'll miss the best things if you keep your eyes shut"
DR_SEUSS_NEW_QUOTE = "Today you are You, that is truer than true. There is no one alive who is Youer than You"
end

0 comments on commit 119e0b2

Please # to comment.