Release Collection #119
This file contains hidden or 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: Release Collection | |
| on: # yamllint disable-line rule:truthy | |
| workflow_dispatch: | |
| env: | |
| NAMESPACE: checkmk | |
| COLLECTION_NAME: general | |
| FILES: "ansible.cfg CHANGELOG.rst galaxy.yml LICENSE README.md" | |
| DIRS: "changelogs docs meta playbooks plugins roles" | |
| jobs: | |
| # | |
| # Run sanity checks prior to release. | |
| # | |
| sanity: | |
| runs-on: ubuntu-24.04 | |
| name: Sanity (Ⓐ${{ matrix.ansible }}) | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| ansible: | |
| - stable-2.17 | |
| - stable-2.18 | |
| - stable-2.19 | |
| - devel | |
| steps: | |
| - name: Check out code | |
| uses: actions/checkout@v5 | |
| with: | |
| path: ansible_collections/${{env.NAMESPACE}}/${{env.COLLECTION_NAME}} | |
| - name: "Install uv." | |
| uses: astral-sh/setup-uv@v7 | |
| with: | |
| enable-cache: true | |
| working-directory: ./ansible_collections/${{env.NAMESPACE}}/${{env.COLLECTION_NAME}}/ | |
| - name: "Create uv venv." | |
| run: uv venv | |
| working-directory: ./ansible_collections/${{env.NAMESPACE}}/${{env.COLLECTION_NAME}} | |
| - name: Install ansible-base (${{ matrix.ansible }}) | |
| run: uv pip install https://github.com/ansible/ansible/archive/${{ matrix.ansible }}.tar.gz | |
| working-directory: ./ansible_collections/${{env.NAMESPACE}}/${{env.COLLECTION_NAME}} | |
| - name: Run sanity tests | |
| run: uv run ansible-test sanity --docker -v --color --coverage | |
| working-directory: ./ansible_collections/${{env.NAMESPACE}}/${{env.COLLECTION_NAME}} | |
| release: | |
| needs: sanity | |
| runs-on: ubuntu-24.04 | |
| steps: | |
| # | |
| # Prepare the environment. | |
| # | |
| - name: "Checkout Code" | |
| uses: actions/checkout@v5 | |
| - name: "Get current Version" | |
| id: current_version | |
| run: echo "version=$(grep 'version:' galaxy.yml | cut -d ' ' -f 2)" >> $GITHUB_OUTPUT | |
| - name: "Install uv." | |
| uses: astral-sh/setup-uv@v7 | |
| with: | |
| enable-cache: true | |
| - name: "Install Dependencies." | |
| run: uv sync | |
| env: | |
| UV_SYSTEM_PYTHON: 1 | |
| # | |
| # First stage: Build and install collection to generate docs and changelogs. | |
| # | |
| - name: "Copy Files and Directories to Source" | |
| run: | | |
| mkdir -p build/src | |
| cp $files build/src | |
| cp -rf $directories build/src | |
| env: | |
| files: ${{env.FILES}} | |
| directories: ${{env.DIRS}} | |
| - name: "Build Ansible Collection" | |
| run: uv run ansible-galaxy collection build build/src --force | |
| - name: "Install Ansible Collection" | |
| run: uv run ansible-galaxy collection install --no-deps ./${{env.NAMESPACE}}-${{env.COLLECTION_NAME}}-${{ steps.current_version.outputs.version }}.tar.gz | |
| - name: "Compile Collection Changelog" | |
| run: uv run antsibull-changelog release | |
| # This is slightly hacky and we might need to adapt it later. | |
| # But for now it looks promising. See the below link for documentation: | |
| # https://docs.github.com/en/actions/using-workflows/workflow-commands-for-github-actions#multiline-strings | |
| - name: "Record Changes for Release" | |
| run: | | |
| { | |
| echo 'CHANGELOG_FRAGMENT<<EOF' | |
| echo "$(git diff CHANGELOG.rst | grep '^+' | tail -n+4 | tr -d '+')" | |
| echo 'EOF' | |
| } >> $GITHUB_ENV | |
| - name: "Compile Collection Docs" | |
| run: uv run antsibull-docs collection --use-current --squash-hierarchy --fail-on-error --dest-dir ./docs/ ${{env.NAMESPACE}}.${{env.COLLECTION_NAME}} | |
| - name: "Create Pull Request for Docs and Changelog against devel branch" | |
| uses: peter-evans/create-pull-request@v7 | |
| with: | |
| commit-message: Update Docs and Changelogs upon Release | |
| signoff: false | |
| branch: changelogs-docs-update-${{ steps.current_version.outputs.version }} | |
| base: devel | |
| delete-branch: true | |
| title: '[Auto] Update changelogs and docs upon release' | |
| body: | | |
| Changelogs and docs updated during *${{ steps.current_version.outputs.version }}* release. | |
| assignees: robin-checkmk | |
| reviewers: robin-checkmk | |
| draft: false | |
| # | |
| # Second stage: Build the final version of the collection and release it. | |
| # | |
| - name: "Copy Files and Directories to Source" | |
| run: | | |
| mkdir -p build/src | |
| cp $files build/src | |
| cp -rf $directories build/src | |
| rm -rf build/src/roles/*/molecule | |
| env: | |
| files: ${{env.FILES}} | |
| directories: ${{env.DIRS}} | |
| - name: "Build Ansible Collection" | |
| run: uv run ansible-galaxy collection build build/src --force | |
| - name: "Create Release and upload Assets" | |
| id: create-release | |
| uses: softprops/action-gh-release@v2 | |
| with: | |
| token: ${{ secrets.GITHUB_TOKEN }} | |
| draft: false | |
| prerelease: false | |
| name: v${{ steps.current_version.outputs.version }} | |
| tag_name: v${{ steps.current_version.outputs.version }} | |
| files: ${{env.NAMESPACE}}-${{env.COLLECTION_NAME}}-${{ steps.current_version.outputs.version }}.tar.gz | |
| body: | | |
| # Ansible Collection: ${{env.NAMESPACE}}.${{env.COLLECTION_NAME}} | |
| For information about this collection and how to install it, refer to the [README](https://github.com/Checkmk/ansible-collection-checkmk.general/blob/main/README.md). | |
| ${{env.CHANGELOG_FRAGMENT}} | |
| For a detailed changelog, refer to the [CHANGELOG](https://github.com/Checkmk/ansible-collection-checkmk.general/blob/main/CHANGELOG.rst). | |
| - name: "Publish Ansible Collection to the Galaxy" | |
| run: uv run ansible-galaxy collection publish ${{env.NAMESPACE}}-${{env.COLLECTION_NAME}}-${{ steps.current_version.outputs.version }}.tar.gz --api-key ${{ secrets.GALAXY_API_KEY }} |