Publish Ansible Galaxy Collection #2
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Publish Ansible Galaxy Collection | |
on: | |
release: | |
types: [published] | |
workflow_dispatch: | |
jobs: | |
publish-collection: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repo content | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Setup Python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: 3.8 | |
- name: Install Ansible | |
run: pip install ansible | |
- name: Determine Ansible Galaxy version | |
run: echo "GALAXY_VERSION=$(echo ${{ github.ref_name }} | cut -c2-)" >> $GITHUB_ENV | |
- name: Update Ansible Galaxy version | |
run: | | |
git config user.name github-actions | |
git config user.email github-actions@github.com | |
git checkout main | |
echo "Updating version to ${{env.GALAXY_VERSION}} in galaxy.yml" | |
sed -i 's/\(version:\) .*/\1 ${{env.GALAXY_VERSION}}/g' galaxy.yml | |
git add galaxy.yml | |
- name: Update changelog | |
run: | | |
python scripts/changelog.py > CHANGELOG.md | |
git add CHANGELOG.md | |
- name: Commit changes | |
run: | | |
git commit -m "Update galaxy version and changelog for release ${{env.GALAXY_VERSION}}" | |
git push origin HEAD:main | |
- name: Update release tag | |
run: | | |
git pull | |
git tag -f ${{ github.ref_name }} | |
git push origin HEAD:main | |
git push origin -f ${{ github.ref_name }} | |
- name: Build Ansible collection | |
run: ansible-galaxy collection build | |
- name: Determine collection artifact name | |
run: echo "ARTIFACT=itential-deployer-${{env.GALAXY_VERSION}}.tar.gz" >> $GITHUB_ENV | |
- name: Publish collection to Ansible Galaxy | |
env: | |
ANSIBLE_API_TOKEN: ${{ secrets.ANSIBLE_API_TOKEN }} | |
run: ansible-galaxy collection publish ${{env.ARTIFACT}} --token $ANSIBLE_API_TOKEN |