feat: Add GitHub Actions Workflow to check for typos (#141) #39
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# workflows/publish-github-release.yml | |
# | |
# Publish GitHub Release | |
# Publish the ParadeDB pg_analytics GitHub Release. | |
name: Publish GitHub Release | |
on: | |
push: | |
branches: | |
- main | |
- dev | |
workflow_dispatch: | |
concurrency: | |
group: publish-github-release-${{ github.head_ref || github.ref }} | |
cancel-in-progress: true | |
jobs: | |
publish-github-release: | |
name: Publish ParadeDB pg_analytics GitHub Release | |
runs-on: depot-ubuntu-latest-2 | |
steps: | |
- name: Checkout Git Repository | |
uses: actions/checkout@v4 | |
- name: Set Environment | |
id: env | |
run: | | |
if [[ "${{ github.ref }}" == "refs/heads/main" ]]; then | |
echo "environment=prod" >> $GITHUB_OUTPUT | |
echo "Using prod configuration..." | |
else | |
echo "environment=dev" >> $GITHUB_OUTPUT | |
echo "Using dev configuration..." | |
fi | |
# We store the GitHub Release version number in GitHub Actions Variables. Since it's | |
# not possible for a GHA variable to be negative, we store the version of the next | |
# release, to allow 0-indexing. This is why we immediately release the version stored, | |
# and increment it after the GitHub release is created. | |
- name: Retrieve & Increment Release Version Number | |
id: version | |
run: | | |
if [[ "${{ steps.env.outputs.environment }}" == "prod" ]]; then | |
echo 'Using prod configuration...' | |
CURRENT_RELEASE_VERSION="${{ vars.VERSION_MAJOR }}.${{ vars.VERSION_MINOR }}.${{ vars.VERSION_PATCH }}" | |
# Increment GHA variable version by 0.0.1 for next release | |
GHA_VAR_NAME="VERSION_PATCH" | |
GHA_VAR_VALUE="$(( ${{ vars.VERSION_PATCH }} + 1 ))" | |
elif [[ "${{ steps.env.outputs.environment }}" == "dev" ]]; then | |
echo 'Using dev configuration...' | |
CURRENT_RELEASE_VERSION="${{ vars.VERSION_MAJOR }}.${{ vars.VERSION_MINOR }}.${{ vars.VERSION_PATCH }}-dev-rc.${{ vars.VERSION_DEV_RC }}" | |
# Increment GHA variable version by dev-rc.1 for next release | |
GHA_VAR_NAME="VERSION_DEV_RC" | |
GHA_VAR_VALUE="$(( ${{ vars.VERSION_DEV_RC }} + 1 ))" | |
else | |
echo "Error: Invalid branch" && false | |
fi | |
# Output the current release version to create the GitHub Release tag, and the new version to update GitHub Actions variable | |
echo "version=${CURRENT_RELEASE_VERSION}" >> $GITHUB_OUTPUT | |
echo "gha_var_name=${GHA_VAR_NAME}" >> $GITHUB_OUTPUT | |
echo "gha_var_value=${GHA_VAR_VALUE}" >> $GITHUB_OUTPUT | |
- name: Update Version Number in GitHub Actions Variables | |
env: | |
GH_TOKEN: ${{ secrets.GHA_CREATE_RELEASE_PAT }} | |
run: | | |
# on prod we update patch and reset dev RC to 0 | |
if [[ "${{ steps.env.outputs.environment }}" == "prod" ]]; then | |
gh api \ | |
--method PATCH \ | |
-H "Accept: application/vnd.github+json" \ | |
-H "X-GitHub-Api-Version: 2022-11-28" \ | |
/repos/paradedb/pg_analytics/actions/variables/${{ steps.version.outputs.gha_var_name }} \ | |
-f name='${{ steps.version.outputs.gha_var_name }}' \ | |
-f value='${{ steps.version.outputs.gha_var_value }}' | |
gh api \ | |
--method PATCH \ | |
-H "Accept: application/vnd.github+json" \ | |
-H "X-GitHub-Api-Version: 2022-11-28" \ | |
/repos/paradedb/pg_analytics/actions/variables/VERSION_DEV_RC \ | |
-f name='VERSION_DEV_RC' \ | |
-f value='0' | |
# on dev we only update dev RC | |
elif [[ "${{ steps.env.outputs.environment }}" == "dev" ]]; then | |
gh api \ | |
--method PATCH \ | |
-H "Accept: application/vnd.github+json" \ | |
-H "X-GitHub-Api-Version: 2022-11-28" \ | |
/repos/paradedb/pg_analytics/actions/variables/${{ steps.version.outputs.gha_var_name }} \ | |
-f name='${{ steps.version.outputs.gha_var_name }}' \ | |
-f value='${{ steps.version.outputs.gha_var_value }}' | |
else | |
echo "Error: Invalid branch" && false | |
fi | |
# We create the GitHub release last in case of failure in previous steps | |
- name: Create GitHub Release (prod only) | |
if: steps.env.outputs.environment == 'prod' | |
uses: softprops/action-gh-release@v2 | |
with: | |
tag_name: v${{ steps.version.outputs.version }} | |
generate_release_notes: true | |
env: | |
GITHUB_TOKEN: ${{ secrets.GHA_CREATE_RELEASE_PAT }} |