Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix publish no version bump no error #1086

Merged
merged 3 commits into from
Mar 13, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 35 additions & 20 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -91,11 +91,12 @@ jobs:
# subsequent steps can choose whether the version has been bumped or not. All we know at this stage is the version has been changed, i.e. new_version != old_version, but we don't know whether new_version > old_version or new_version < old_version
if [[ -n "$version_changes" ]]; then
echo "version has changed"
echo "bump=true" >> $GITHUB_OUTPUT
else
echo "version has not changed"
# fail here if the version has not changed, we don't want to publish anything if the version has not changed!
echo "non-manual run, failing"
exit 1
# skip remaining steps which bump the version
echo "bump=false" >> $GITHUB_OUTPUT
exit 0
fi

VERSION=$(cat package.json | jq -r '.version' || echo "0.0.0")
Expand All @@ -117,7 +118,7 @@ jobs:
# check for version bump against github release
- name: Check version github
id: check_version_github

if: steps.next_version.outputs.bump == 'true'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
Expand Down Expand Up @@ -154,6 +155,7 @@ jobs:

- name: Check version npm
id: check_version_npm
if: steps.next_version.outputs.bump == 'true'
run: |
# get the current version number from latest release on npm (use procaptcha as the baseline, as workspace package is not published)
VERSION=$(npm view @prosopo/procaptcha version)
Expand Down Expand Up @@ -188,6 +190,7 @@ jobs:

- name: Check version docker js_server
id: check_version_docker_js_server
if: steps.next_version.outputs.bump == 'true'
run: |
# get the current version number from latest release on docker
VERSION=$(curl -L -s 'https://registry.hub.docker.com/v2/repositories/prosopo/js_server/tags/' | jq ".results[].name" | grep -E -o "[0-9]+\.[0-9]+\.[0-9]+" | head -n 1)
Expand Down Expand Up @@ -222,6 +225,7 @@ jobs:

- name: Check version docker provider
id: check_version_docker_provider
if: steps.next_version.outputs.bump == 'true'
run: |
# get the current version number from latest release on docker
VERSION=$(curl -L -s 'https://registry.hub.docker.com/v2/repositories/prosopo/provider/tags/' | jq ".results[].name" | grep -E -o "[0-9]+\.[0-9]+\.[0-9]+" | head -n 1)
Expand Down Expand Up @@ -257,22 +261,30 @@ jobs:
- name: Should bump?
id: check_version_any
run: |
bump=false
# only bump if any of the version checks have detected a bump
if [[ "${{ steps.check_version_github.outputs.bump }}" == 'true' ]]; then
echo "bump=true" >> $GITHUB_OUTPUT
bump=true
echo "github bump required"
elif [[ "${{ steps.check_version_npm.outputs.bump }}" == 'true' ]]; then
echo "bump=true" >> $GITHUB_OUTPUT
fi
if [[ "${{ steps.check_version_npm.outputs.bump }}" == 'true' ]]; then
bump=true
echo "npm bump required"
elif [[ "${{ steps.check_version_docker_js_server.outputs.bump }}" == 'true' ]]; then
echo "bump=true" >> $GITHUB_OUTPUT
fi
if [[ "${{ steps.check_version_docker_js_server.outputs.bump }}" == 'true' ]]; then
bump=true
echo "docker js_server bump required"
elif [[ "${{ steps.check_version_docker_provider.outputs.bump }}" == 'true' ]]; then
echo "bump=true" >> $GITHUB_OUTPUT
fi
if [[ "${{ steps.check_version_docker_provider.outputs.bump }}" == 'true' ]]; then
bump=true
echo "docker provider bump required"
fi
if [[ "$bump" == 'true' ]]; then
echo "bump=true" >> $GITHUB_OUTPUT
echo "something needs bumping"
else
echo "bump=false" >> $GITHUB_OUTPUT
echo "no bump required"
echo "nothing needs bumping"
fi

# setup node
Expand Down Expand Up @@ -502,7 +514,6 @@ jobs:
npx tsx ./dev/flux/dist/index.js deploy --app ProcaptchaJavascriptServer
else
echo "Skipping flux redeploy."
exit 1
fi

- name:
Expand All @@ -511,14 +522,18 @@ jobs:
PROSOPO_ZELCORE_PRIVATE_KEY: ${{ secrets.PROSOPO_ZELCORE_PRIVATE_KEY }}
PROSOPO_ZELCORE_PUBLIC_KEY: ${{ secrets.PROSOPO_ZELCORE_PUBLIC_KEY }}
run: |
if [[ "${{ steps.redeploy_flux_docker_js_server.outcome }}" == 'success' ]]; then
echo "Redeployed flux docker js_server."
curl -X POST -H 'Content-type: application/json' --data "{\"text\":\":check-passed: Flux docker js_server redeploy <${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}|v${{ steps.next_version.outputs.version }}> has been requested.\"}" ${{ secrets.SLACKBOT_DEVOPS }}
elif [[ "${{ steps.redeploy_flux_docker_js_server.outcome }}" == 'failure' ]]; then
echo "Redeploying flux docker js_server failed."
curl -X POST -H 'Content-type: application/json' --data "{\"text\":\":check-failed: Flux docker js_server redeploy <${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}|v${{ steps.next_version.outputs.version }}> failed.\"}" ${{ secrets.SLACKBOT_DEVOPS }}
if [[ "${{ steps.publish_docker_js_server.outcome }}" == 'success' ]]; then
if [[ "${{ steps.redeploy_flux_docker_js_server.outcome }}" == 'success' ]]; then
echo "Redeployed flux docker js_server."
curl -X POST -H 'Content-type: application/json' --data "{\"text\":\":check-passed: Flux docker js_server redeploy <${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}|v${{ steps.next_version.outputs.version }}> has been requested.\"}" ${{ secrets.SLACKBOT_DEVOPS }}
elif [[ "${{ steps.redeploy_flux_docker_js_server.outcome }}" == 'failure' ]]; then
echo "Redeploying flux docker js_server failed."
curl -X POST -H 'Content-type: application/json' --data "{\"text\":\":check-failed: Flux docker js_server redeploy <${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}|v${{ steps.next_version.outputs.version }}> failed.\"}" ${{ secrets.SLACKBOT_DEVOPS }}
else
echo "Redeploying flux docker js_server skipped / cancelled."
fi
else
echo "Redeploying flux docker js_server skipped / cancelled."
echo "Skipping flux redeploy notification."
fi

- name: Build and Push the Provider Bundle
Expand Down
Loading