Skip to content

Commit

Permalink
ci: upload collection artifact to GH release (#327)
Browse files Browse the repository at this point in the history
Signed-off-by: Alex <[email protected]>
  • Loading branch information
Alex-Izquierdo authored Sep 23, 2024
1 parent 08c4888 commit a219695
Showing 1 changed file with 23 additions and 3 deletions.
26 changes: 23 additions & 3 deletions .github/workflows/tox.yml
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,10 @@ jobs:
with:
name: collection-artifact

- name: Set tarball as environment variable
id: set_tarball
run: echo "TARBALL=$(ls -1 ./*.tar.gz)" >> $GITHUB_ENV

- name: Setup python
uses: actions/setup-python@v5
with:
Expand All @@ -269,7 +273,23 @@ jobs:
[[ "${{ secrets.ANSIBLE_GALAXY_API_KEY != '' }}" ]] || { echo
"ANSIBLE_GALAXY_API_KEY is required to publish on galaxy" ; exit 1; }
TARBALL=$(ls -1 ./*.tar.gz)
ansible-galaxy collection publish "${TARBALL}" --api-key "${{
ansible-galaxy collection publish "${{ env.TARBALL }}" --api-key "${{
secrets.ANSIBLE_GALAXY_API_KEY }}"
- name: Upload the artifact to the release
if: github.ref_type == 'tag'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
TAG_NAME=$(echo ${{ github.ref }} | sed 's/refs\/tags\///')
# Check if a release exists for the current tag
RELEASE_EXISTS=$(gh release view $TAG_NAME --json id --jq '.id' || echo "no_release")
# If a release exists, upload the artifact
if [ "$RELEASE_EXISTS" != "no_release" ]; then
echo "Release found for tag $TAG_NAME. Uploading artifact."
gh release upload $TAG_NAME "${{ env.TARBALL }}"
else
echo "No release found for tag $TAG_NAME. Skipping artifact upload."
fi

0 comments on commit a219695

Please sign in to comment.