forked from paradedb/pg_analytics
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: Add publish CI for pg_analytics (paradedb#68)
* Add publish for pg_analytics * Integrate in the new repo
- Loading branch information
1 parent
ad5b716
commit 5cd2501
Showing
2 changed files
with
553 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,111 @@ | ||
# 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/paradedb/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/paradedb/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/paradedb/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 }} |
Oops, something went wrong.