Skip to content

Publish to Ansible Galaxy #14

Publish to Ansible Galaxy

Publish to Ansible Galaxy #14

Workflow file for this run

name: Publish to Ansible Galaxy
on:
workflow_dispatch:
jobs:
publish:
environment: publish
runs-on: ubuntu-latest
outputs:
version: ${{ steps.build.outputs.version }}
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Build
id: build
run: |
OUTPUT=$(ansible-galaxy collection build)
echo "$OUTPUT"
COLLECTION_PATH=$(echo "$OUTPUT" | grep -o '/[^ ]*\.tar\.gz')
VERSION=$(echo "$COLLECTION_PATH" | grep -o -E '[0-9]+\.[0-9]+\.[0-9]+\.tar\.gz' | sed 's/\.tar\.gz//')
echo "collection_path=$COLLECTION_PATH" >> $GITHUB_OUTPUT
echo "version=$VERSION" >> $GITHUB_OUTPUT
echo "Collection path: $COLLECTION_PATH"
echo "Collection version: $VERSION"
- name: Publish to Ansible Galaxy
run: ansible-galaxy collection publish ${{ steps.build.outputs.collection_path }} --api-key ${{ secrets.ANSIBLE_GALAXY_TOKEN }}
- name: Upload Artifact
uses: actions/[email protected]
with:
name: ansible-dvls-collection
path: ${{ steps.build.outputs.collection_path }}
create-release:
name: Create release
runs-on: ubuntu-latest
needs: publish
steps:
- name: Check out ${{ github.repository }}
uses: actions/checkout@v4
with:
fetch-depth: 0 # fetch all tags for the set version step
- name: Create release
id: create-release
uses: devolutions/actions/create-release@v1
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
tag: v${{ needs.publish.outputs.version }}