-
Notifications
You must be signed in to change notification settings - Fork 2
54 lines (46 loc) · 1.7 KB
/
publish-release.yml
File metadata and controls
54 lines (46 loc) · 1.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
name: Release and Publish Ansible Collection
on:
workflow_dispatch:
jobs:
release:
runs-on: ubuntu-latest
steps:
- name: Checkout stable-10 Branch
uses: actions/checkout@v6
with:
ref: stable-10
- name: Set up Python
uses: actions/setup-python@v6
with:
python-version: '3.x'
- name: Install Dependencies
run: |
pip install ansible antsibull-changelog
- name: Extract Collection Version
id: extract_version
run: |
# Extract the version from galaxy.yml (assumes the line "version: <value>" exists)
version=$(grep "^version:" galaxy.yml | awk '{print $2}')
echo "Collection version: $version"
echo "version=$version" >> $GITHUB_OUTPUT
- name: Create GitHub Release
id: create_release
uses: softprops/action-gh-release@v3
with:
tag_name: ${{ steps.extract_version.outputs.version }}
name: ${{ steps.extract_version.outputs.version }}
body_path: CHANGELOG.md
draft: false
prerelease: false
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Build Ansible Collection
run: ansible-galaxy collection build --force
- name: Publish to Ansible Galaxy
run: |
# The tarball name follows the <namespace>-<collection>-<version>.tar.gz convention.
tarball=$(find . -maxdepth 1 -name '*.tar.gz' | head -n 1)
echo "Publishing collection tarball: $tarball"
ansible-galaxy collection publish "$tarball" --api-key $ANSIBLE_GALAXY_API_KEY
env:
ANSIBLE_GALAXY_API_KEY: ${{ secrets.ANSIBLE_GALAXY_API_KEY }}