Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
107 changes: 107 additions & 0 deletions .github/workflows/create-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
name: Create Release Branch
run-name: "Create release branch (bump ${{ inputs.bump_type }})"

on:
workflow_dispatch:
inputs:
bump_type:
description: 'Version component to bump'
required: true
default: 'minor'
type: choice
options:
- minor
- major
- fix

permissions:
contents: write

jobs:
create-release:
name: "Bump ${{ inputs.bump_type }} version"
runs-on: ubuntu-latest

steps:
- name: Checkout main
uses: actions/checkout@f9e715a95fcd1f9253f77dd28f11e88d2d6460c7 # v6.0.3
with:
ref: main
fetch-depth: 1

- name: Calculate next version
id: version
run: |
# Calculate the next version based on the bump type (minor or major)
echo "::group::Calculating next version"
current=$(python3 -c "
import re
m = re.search(r'^version:\s*(\S+)', open('galaxy.yml').read(), re.MULTILINE)
print(m.group(1))
")

next=$(python3 -c "
major, minor, patch = (int(x) for x in '${current}'.split('.'))
if '${{ inputs.bump_type }}' == 'major':
print(f'{major+1}.0.0')
elif '${{ inputs.bump_type }}' == 'minor':
print(f'{major}.{minor+1}.0')
else:
print(f'{major}.{minor}.{patch+1}')
")

echo "current=${current}" >> "$GITHUB_OUTPUT"
echo "next=${next}" >> "$GITHUB_OUTPUT"
echo "branch=release/${next}" >> "$GITHUB_OUTPUT"
echo "::endgroup::"

echo "Current : ${current}"
echo "Next : ${next}"
echo "Branch : release/${next}"

- name: Abort if branch already exists
run: |
# Check if the release branch already exists on origin
branch="${{ steps.version.outputs.branch }}"
if git ls-remote --exit-code --heads origin "$branch" > /dev/null 2>&1; then
echo "ERROR: $branch already exists on origin"
exit 1
fi

- name: Configure git identity
run: |
# Configure git identity for GitHub Actions bot
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"

- name: Create release branch
run: git checkout -b "${{ steps.version.outputs.branch }}"

- name: Create changelog summary
env:
NEXT_VERSION: ${{ steps.version.outputs.next }}
run: |
# Create an empty changelog summary file for the new version
SUMMARY_FILE="changelogs/fragments/v${NEXT_VERSION}_summary.yaml"
echo -e "release_summary: ''" > ${SUMMARY_FILE}
git add ${SUMMARY_FILE}

- name: Commit and push release branch
run: |
# Commit and push the release branch to origin
git commit -m "Create release branch"
git push origin "${{ steps.version.outputs.branch }}"

- name: Job summary
run: |
cat >> "$GITHUB_STEP_SUMMARY" <<EOF
### Release branch created

| Type | Value |
|------|-------|
| Previous version | \`${{ steps.version.outputs.current }}\` |
| New version | \`${{ steps.version.outputs.next }}\` |
| Branch | \`${{ steps.version.outputs.branch }}\` |

**Next step:** trigger the [Release workflow](../workflows/release.yml) with version \`${{ steps.version.outputs.next }}\`.
EOF
56 changes: 34 additions & 22 deletions .github/workflows/release-tests.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: Collection Tests
run-name: "${{ inputs.test_type || 'all' }} / ${{ github.head_ref || github.ref_name }} / zbx ${{ inputs.zabbix_version || '7.0' }}"
run-name: "Release Tests: ${{ github.head_ref || github.ref_name }}"

on:
pull_request:
Expand Down Expand Up @@ -27,7 +27,7 @@ on:
ansible_core:
description: 'ansible-core version(s), as a JSON array, e.g. ["2.20"] or ["2.18","2.19"]'
required: false
default: '["2.17"]'
default: '["2.18","2.19","2.20"]'
type: string
zabbix_version:
description: 'Zabbix version (for integration tests)'
Expand All @@ -41,33 +41,45 @@ on:
permissions:
contents: read

env:
TEST_TYPE: ${{ inputs.test_type || 'all' }}
ZABBIX_VERSION: ${{ inputs.zabbix_version || '7.0' }}
SRC_DIR: ${{ github.workspace }}
COLLECTIONS_PATH: /home/runner/.ansible/collections
COLLECTION_DIR: /home/runner/.ansible/collections/ansible_collections/zabbix/zabbix

jobs:
init:
name: "Initialize workflow"
runs-on: ubuntu-latest
outputs:
test_type: ${{ inputs.test_type || 'all' }}
ansible_lint_version: ${{ inputs.ansible_lint_version || ''}}
ansible_core: ${{ inputs.ansible_core || '["2.18","2.19","2.20"]'}}
zabbix_version: ${{ inputs.zabbix_version || '7.0' }}
steps:
- name: Init workflow
run: |
# Init workflow
echo "Workflow initialized"
test:
name: "ansible-core ${{ matrix.ansible_version }}"
name: "${{ needs.init.outputs.test_type }} / ansible-core ${{ matrix.ansible_version }} / zbx ${{ needs.init.outputs.zabbix_version }}"
runs-on: ansible-test-collection
timeout-minutes: 180
needs: init

env:
TEST_TYPE: ${{ needs.init.outputs.test_type }}
ZABBIX_VERSION: ${{ needs.init.outputs.zabbix_version }}
SRC_DIR: ${{ github.workspace }}
COLLECTIONS_PATH: /home/runner/.ansible/collections
COLLECTION_DIR: /home/runner/.ansible/collections/ansible_collections/zabbix/zabbix
LANG: en_US.UTF-8
LC_ALL: en_US.UTF-8
COMPOSE_FILE: .github/docker-compose.yml

# cancel-in-progress only on pull_request; preserve scheduled and dispatch runs.
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}-${{ inputs.test_type || 'all' }}-${{ matrix.ansible_version }}
group: ${{ github.workflow }}-${{ github.ref }}-${{ needs.init.outputs.test_type }}-${{ matrix.ansible_version }}
cancel-in-progress: true

strategy:
fail-fast: false
matrix:
ansible_version: ${{ inputs.ansible_core && fromJSON(inputs.ansible_core) || fromJSON('["2.17"]') }}

env:
LANG: en_US.UTF-8
LC_ALL: en_US.UTF-8
COMPOSE_FILE: .github/docker-compose.yml
ansible_version: ${{ needs.init.outputs.ansible_core && fromJSON(needs.init.outputs.ansible_core) }}

steps:
- name: Checkout
Expand Down Expand Up @@ -141,7 +153,7 @@ jobs:
- name: Install ansible-core ${{ matrix.ansible_version }} and tools
env:
ANSIBLE_CORE_VERSION: ${{ matrix.ansible_version }}
ANSIBLE_LINT_VERSION: ${{ inputs.ansible_lint_version || '25.5.0' }} # TODO: remove default once 25.5.0 is the minimum supported version
ANSIBLE_LINT_VERSION: ${{ needs.init.outputs.ansible_lint_version }}
run: |
# Install ansible-core
lint_req="ansible-lint"
Expand Down Expand Up @@ -198,10 +210,10 @@ jobs:
[ -d roles ] || { echo "roles directory not found"; exit 1; }
[ -d plugins ] || { echo "plugins directory not found"; exit 1; }

# - name: Validate changelog
# working-directory: ${{ env.SRC_DIR }}
# if: env.TEST_TYPE == 'lint' || env.TEST_TYPE == 'all'
# run: antsibull-changelog lint
- name: Validate changelog
working-directory: ${{ env.SRC_DIR }}
if: env.TEST_TYPE == 'lint' || env.TEST_TYPE == 'all'
run: antsibull-changelog lint

# ZABBIX_VERSION (workflow-level env) is interpolated by compose into image tags.
- name: Start Zabbix stack
Expand Down
Loading
Loading