Skip to content

Deploy

Deploy #3

Workflow file for this run

name: Deploy
on:
workflow_dispatch:
inputs:
version_type:
description: "The type of the release"
required: true
type: choice
options:
- major
- minor
- patch
jobs:
deploy:
name: Deploy
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Update version
run: |
set -e
current_version=$(grep -oP 'const PluginVersion = "\K[0-9]+\.[0-9]+\.[0-9]+' internal/core/constants.go)
if [[ -z "$current_version" ]]; then
echo "Error: Unable to find PluginVersion"
exit 1
fi
IFS='.' read -r MAJOR MINOR PATCH <<< "$current_version"
if [[ "${{ inputs.version_type }}" == "major" ]]; then
((MAJOR++))
MINOR=0
PATCH=0
elif [[ "${{ inputs.version_type }}" == "minor" ]]; then
((MINOR++))
PATCH=0
elif [[ "${{ inputs.version_type }}" == "patch" ]]; then
((PATCH++))
else
echo "Error: Invalid version type. Use 'major', 'minor', or 'patch'."
exit 1
fi
new_version="$MAJOR.$MINOR.$PATCH"
echo "new plugin version is: $new_version"
sed -i "s/const PluginVersion = \"[0-9]\+\.[0-9]\+\.[0-9]\+\"/const PluginVersion = \"$new_version\"/" internal/core/constants.go
echo "VERSION=v$new_version" >> $GITHUB_OUTPUT
- name: Commit Changes
uses: stefanzweifel/git-auto-commit-action@v5
with:
commit_message: "Bump version for release"
file_pattern: "internal/core/*.go"
- name: Setup Go
uses: actions/setup-go@v5
with:
go-version-file: './go.mod'
- name: Build plugin
working-directory: plugin
run: GOOS=wasip1 GOARCH=wasm go build -o ../tests/sqlc-gen-java.wasm
- name: Create tag
run: |
git tag ${{ steps.update-version.outputs.VERSION }}
git push origin ${{ steps.update-version.outputs.VERSION }}
- name: Generate release description
run: |
export checksum=$(sha256sum sqlc-gen-java.wasm | awk '{print $1}')
export download_url="https://github.com/tandemdude/releases/download/${{ steps.update-version.outputs.VERSION }}/sqlc-gen-java.wasm"
yq -i '.plugins[0].wasm.url = env(download_url)' .github/release_output_template.yaml
yq -i '.plugins[0].wasm.sha256 = env(checksum)' .github/release_output_template.yaml
echo "\`\`\`yaml" > release_body.md
cat .github/release_output_template.yaml >> release_body.md
echo "\`\`\`" >> release_body.md
- name: Create release
uses: softprops/action-gh-release@v2
with:
token: "${{ secrets.GITHUB_TOKEN }}"
name: "${{ steps.update-version.outputs.VERSION }}"
tag_name: "refs/tags/${{ steps.update-version.outputs.VERSION }}"
body_path: release_body.md
files: sqlc-gen-java.wasm