Add Galaxy overwrite check and use gh for release#357
Conversation
Add a new boolean workflow input overwrite_existing (default false) and expose it as OVERWRITE_EXISTING. Add a step that checks whether the specified VERSION tarball already exists on Ansible Galaxy (sets step output exists) and a conditional step that aborts the run unless overwrite_existing=true. Replace the softprops/action-gh-release step with a gh CLI release create invocation that uses VERSION and RELEASE_DESCRIPTION. These changes prevent accidental duplicate Galaxy publishes and allow explicit overwriting while simplifying release creation.
Use shutil.which('pwsh') to locate the pwsh executable dynamically, falling back to platform-specific defaults (/usr/local/bin/pwsh on macOS, /usr/bin/pwsh otherwise) if not found. This improves portability across different environments and CI runners where pwsh may be installed in non-standard locations.
There was a problem hiding this comment.
Pull request overview
This PR updates the project’s release automation and integration test tooling by enhancing the GitHub Actions release workflow (Galaxy prechecks, artifact upload, gh-based GitHub release creation) and making the local_pwsh connection plugin more robust by dynamically locating the pwsh executable.
Changes:
- Add release workflow preflight checks (Galaxy version existence +
galaxy.ymlversion match) and anoverwrite_existinginput gate. - Upload the built collection tarball as a workflow artifact after publishing.
- Replace
softprops/action-gh-releasewithgh release createfor GitHub release creation. - Update the
local_pwshtest connection plugin to resolvepwshviashutil.which()with platform fallbacks.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
tests/integration/targets/setup_sqlserver_test_plugins/connection_plugins/local_pwsh.py |
Resolve pwsh dynamically to avoid hard-coded install paths breaking tests on newer environments. |
.github/workflows/release.yml |
Add Galaxy/version validation logic, optional overwrite gate, artifact upload, and switch to gh for GitHub releases. |
| if curl --head -s -f -o /dev/null "https://galaxy.ansible.com/download/lowlydba-sqlserver-${VERSION}.tar.gz"; then | ||
| echo "exists=true" >> "$GITHUB_OUTPUT" | ||
| echo "Version ${VERSION} already exists on Galaxy" | ||
| else | ||
| echo "exists=false" >> "$GITHUB_OUTPUT" | ||
| echo "Version ${VERSION} does not yet exist on Galaxy" |
There was a problem hiding this comment.
The Galaxy existence check treats any curl failure (network/DNS/timeout/5xx) the same as “version does not exist” and proceeds, which can lead to attempting a publish/release under uncertain Galaxy availability. Consider capturing the HTTP status explicitly and only treating 404 as “does not exist”; for other non-success statuses or curl transport errors, fail the job so the release isn’t created based on a false negative.
| if curl --head -s -f -o /dev/null "https://galaxy.ansible.com/download/lowlydba-sqlserver-${VERSION}.tar.gz"; then | |
| echo "exists=true" >> "$GITHUB_OUTPUT" | |
| echo "Version ${VERSION} already exists on Galaxy" | |
| else | |
| echo "exists=false" >> "$GITHUB_OUTPUT" | |
| echo "Version ${VERSION} does not yet exist on Galaxy" | |
| GALAXY_URL="https://galaxy.ansible.com/download/lowlydba-sqlserver-${VERSION}.tar.gz" | |
| if HTTP_STATUS=$(curl --head -s -o /dev/null -w "%{http_code}" "${GALAXY_URL}"); then | |
| case "${HTTP_STATUS}" in | |
| 200) | |
| echo "exists=true" >> "$GITHUB_OUTPUT" | |
| echo "Version ${VERSION} already exists on Galaxy" | |
| ;; | |
| 404) | |
| echo "exists=false" >> "$GITHUB_OUTPUT" | |
| echo "Version ${VERSION} does not yet exist on Galaxy" | |
| ;; | |
| *) | |
| echo "::error::Unexpected HTTP status ${HTTP_STATUS} while checking whether version ${VERSION} exists on Galaxy." | |
| exit 1 | |
| ;; | |
| esac | |
| else | |
| echo "::error::Failed to query Galaxy for version ${VERSION}." | |
| exit 1 |
Description
Added a new
overwrite_existingboolean input to the release workflow, allowing users to overwrite an existing Galaxy release if needed. The workflow now checks if the specified version already exists and aborts unless overwriting is explicitly enabled.Added a validation step to ensure the input version matches the version specified in
galaxy.yml, preventing accidental mismatches during release.Improved artifact handling by uploading the built collection as a workflow artifact after publishing to Galaxy.
Replaced the use of the
softprops/action-gh-releaseaction with a directgh release createcommand for creating GitHub releases, simplifying the release step and reducing dependencies.Updated the
local_pwsh.pytest connection plugin to dynamically locate thepwshexecutable usingshutil.which, with platform-specific fallbacks, making the test setup more robust across different environments.pwshinstall directory is more of a moving target these days than when it first came out, so using dynamic resolution is needed as of 2.21+How Has This Been Tested?
Types of changes
Checklist:
version_addedproperty.