Skip to content

Publish to Galaxy

Publish to Galaxy #9

Workflow file for this run

name: Publish to Galaxy
# Run this workflow every time a tag is pushed to the repo
on:
push:
tags:
# The regex for semantic versioning should be (the second here: https://semver.org/#is-there-a-suggested-regular-expression-regex-to-check-a-semver-string)
# - "^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?$"
- "[0-9]+.[0-9]+.[0-9]+"
workflow_run:
workflows: [Run ansible-lint]
types:
- completed
jobs:
check-version:
name: Check tag version matches version in galaxy.yml
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Extract version from galaxy.yml
run: |
echo "galaxy_version=`sed -n 's/^version: \(.*\)/\1/p' < galaxy.yml`" >> "$GITHUB_ENV"
- name: Extract tag name
run: |
echo "tag_version=${GITHUB_REF#refs/*/}" >> "$GITHUB_ENV"
- name: Compare version to tag version
if: ${{ env.galaxy_version != env.tag_version }}
run: |
echo "::error ::Version in galaxy.yml does not match the tag version."
exit 1
build-collection:
name: Build collection
needs:
- check-version
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Build tar
run: ansible-galaxy collection build -f
- name: Publish collection
env:
VERSION: ${{ env.tag_version }}
run: ansible-galaxy collection publish maykinmedia-commonground-$VERSION.tar.gz --token ${{ secrets.GALAXY_API_KEY }}"