Skip to content

Commit

Permalink
[release] split release
Browse files Browse the repository at this point in the history
  • Loading branch information
SockworkOrange committed Jun 29, 2024
1 parent d49fbcd commit f2d5018
Show file tree
Hide file tree
Showing 3 changed files with 102 additions and 72 deletions.
86 changes: 15 additions & 71 deletions .github/workflows/main.yml → .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Main
name: CI
defaults:
run:
shell: bash
Expand Down Expand Up @@ -121,18 +121,16 @@ jobs:
- name: End-to-End Tests
run: ./scripts/tests/run_end2end.sh

release:
name: Release


release-tag:
name: Release Tag
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/main' && contains(github.event.head_commit.message, '[release]')
needs: [build, end2end-tests]
#if: contains(github.event.head_commit.message, '[release]')
needs: [ build, end2end-tests ]

steps:
- name: Check out Git repository
uses: actions/checkout@v4
with:
fetch-depth: 0

- uses: actions/checkout@v4
- uses: actions/download-artifact@v4
with:
name: wasm-file
Expand All @@ -143,14 +141,14 @@ jobs:
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}')
Expand All @@ -164,13 +162,13 @@ jobs:
esac
return NEW_TAG
}
set -e
echo "Extract the latest tag version"
LATEST_TAG_COMMIT=$(git rev-list --tags --max-count=1)
LATEST_COMMIT_MSG=$(git log -1 --pretty=%B)
if [ -z $LATEST_TAG_COMMIT ]; then
NEW_TAG="0.10.0" # default 1st release version
else
Expand All @@ -184,58 +182,4 @@ jobs:
# Create a new tag
git tag $NEW_TAG
git push origin $NEW_TAG
- name: Calculate sha256
run: |
SHA256_HASH=$(sha256sum plugin.wasm | awk '{ print $1 }')
echo "SHA256_HASH=$SHA256_HASH" >> $GITHUB_ENV
echo "The calculated sha256 is $SHA256_HASH"
- name: Create release draft
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
set -e
LATEST_TAG=${{ env.LATEST_TAG }}
NEW_TAG=${{ env.NEW_TAG }}
SHA256_HASH=${{ env.SHA256_HASH }}
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
## Release version $NEW_TAG
Release sha256 is \`$SHA256_HASH\`
## Configuration example
\`\`\`yaml
version: '2'
plugins:
- name: ruby
wasm:
url: https://github.com/DaredevilOSS/sqlc-gen-ruby/releases/download/$NEW_TAG/sqlc-gen-ruby.wasm
sha256: $SHA256_HASH
\`\`\`
## Changelog
$CHANGE_LOG
## Contributors
* @SockworkOrange
EOF
)
# change file name to convention
mv plugin.wasm sqlc-gen-ruby.wasm
# Create a draft release
gh release create $NEW_TAG sqlc-gen-ruby.wasm \
--draft \
--title "$NEW_TAG" \
--notes "$RELEASE_NOTES"
git push origin $NEW_TAG
1 change: 0 additions & 1 deletion .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ on:
- "examples/**"
- "tests/**"
- "Drivers/**"
- "!ruby-wasm-poc/**"

jobs:
generate-and-push-docs:
Expand Down
87 changes: 87 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
name: Release
defaults:
run:
shell: bash

permissions:
contents: write
pull-requests: write

on:
push:
tags:
- v*
branches: [ "main" ]

jobs:
release:
name: Release
runs-on: ubuntu-latest
steps:
- name: Check out Git repository
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Download artifact
id: download-artifact
uses: dawidd6/action-download-artifact@v6
with:
github_token: ${{secrets.GITHUB_TOKEN}}
workflow: ci
workflow_conclusion: success
name: wasm-file

- name: Calculate sha256
run: |
SHA256_HASH=$(sha256sum plugin.wasm | awk '{ print $1 }')
echo "SHA256_HASH=$SHA256_HASH" >> $GITHUB_ENV
echo "The calculated sha256 is $SHA256_HASH"
- name: Create release draft
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
set -e
LATEST_TAG=${{ env.LATEST_TAG }}
NEW_TAG=${{ env.NEW_TAG }}
SHA256_HASH=${{ env.SHA256_HASH }}
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
## Release version $NEW_TAG
Release sha256 is \`$SHA256_HASH\`
## Configuration example
\`\`\`yaml
version: '2'
plugins:
- name: ruby
wasm:
url: https://github.com/DaredevilOSS/sqlc-gen-ruby/releases/download/$NEW_TAG/sqlc-gen-ruby.wasm
sha256: $SHA256_HASH
\`\`\`
## Changelog
$CHANGE_LOG
## Contributors
* @SockworkOrange
EOF
)
# change file name to convention
mv plugin.wasm sqlc-gen-ruby.wasm
# Create a draft release
gh release create $NEW_TAG sqlc-gen-ruby.wasm \
--draft \
--title "$NEW_TAG" \
--notes "$RELEASE_NOTES"

0 comments on commit f2d5018

Please # to comment.