|
| 1 | +--- |
| 2 | +name: Release collection |
| 3 | +on: |
| 4 | + workflow_dispatch: |
| 5 | + |
| 6 | +jobs: |
| 7 | + release: |
| 8 | + runs-on: ubuntu-latest |
| 9 | + if: github.repository == 'ansible-middleware/common' |
| 10 | + permissions: |
| 11 | + actions: write |
| 12 | + checks: write |
| 13 | + contents: write |
| 14 | + deployments: write |
| 15 | + packages: write |
| 16 | + pages: write |
| 17 | + outputs: |
| 18 | + tag_version: ${{ steps.get_version.outputs.TAG_VERSION }} |
| 19 | + steps: |
| 20 | + - name: Checkout code |
| 21 | + uses: actions/checkout@v3 |
| 22 | + with: |
| 23 | + fetch-depth: 0 |
| 24 | + token: ${{ secrets.TRIGGERING_PAT }} |
| 25 | + |
| 26 | + - name: Set up Python |
| 27 | + uses: actions/setup-python@v1 |
| 28 | + with: |
| 29 | + python-version: "3.x" |
| 30 | + |
| 31 | + - name: Get current version |
| 32 | + id: get_version |
| 33 | + run: echo "::set-output name=TAG_VERSION::$(grep version galaxy.yml | awk -F'"' '{ print $2 }')" |
| 34 | + |
| 35 | + - name: Check if tag exists |
| 36 | + id: check_tag |
| 37 | + run: echo "::set-output name=TAG_EXISTS::$(git tag | grep ${{ steps.get_version.outputs.TAG_VERSION }})" |
| 38 | + |
| 39 | + - name: Fail if tag exists |
| 40 | + if: ${{ steps.get_version.outputs.TAG_VERSION == steps.check_tag.outputs.TAG_EXISTS }} |
| 41 | + uses: actions/github-script@v3 |
| 42 | + with: |
| 43 | + script: | |
| 44 | + core.setFailed('Release tag already exists') |
| 45 | +
|
| 46 | + - name: Install dependencies |
| 47 | + run: | |
| 48 | + python -m pip install --upgrade pip |
| 49 | + pip install ansible-core antsibull |
| 50 | + sudo apt install -y sed hub |
| 51 | +
|
| 52 | + - name: Build collection |
| 53 | + run: | |
| 54 | + ansible-galaxy collection build . |
| 55 | +
|
| 56 | + - name: Create changelog and documentation |
| 57 | + uses: ansible-middleware/collection-docs-action@main |
| 58 | + with: |
| 59 | + collection_fqcn: middleware_automation.common |
| 60 | + collection_repo: ansible-middleware/common |
| 61 | + dependencies: false |
| 62 | + commit_changelog: true |
| 63 | + commit_ghpages: false |
| 64 | + changelog_release: true |
| 65 | + generate_docs: false |
| 66 | + token: ${{ secrets.GITHUB_TOKEN }} |
| 67 | + |
| 68 | + - name: Publish collection |
| 69 | + env: |
| 70 | + ANSIBLE_GALAXY_API_KEY: ${{ secrets.ANSIBLE_GALAXY_API_KEY }} |
| 71 | + run: | |
| 72 | + ansible-galaxy collection publish *.tar.gz --api-key $ANSIBLE_GALAXY_API_KEY |
| 73 | +
|
| 74 | + - name: Create release tag |
| 75 | + run: | |
| 76 | + git config user.name github-actions |
| 77 | + git config user.email github-actions@github.com |
| 78 | + git tag -a ${{ steps.get_version.outputs.TAG_VERSION }} -m "Release v${{ steps.get_version.outputs.TAG_VERSION }}" || true |
| 79 | + git push origin --tags |
| 80 | +
|
| 81 | + - name: Publish Release |
| 82 | + uses: softprops/action-gh-release@v1 |
| 83 | + env: |
| 84 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 85 | + with: |
| 86 | + tag_name: ${{ steps.get_version.outputs.TAG_VERSION }} |
| 87 | + files: "*.tar.gz" |
| 88 | + body_path: gh-release.md |
| 89 | + |
| 90 | + dispatch: |
| 91 | + needs: release |
| 92 | + strategy: |
| 93 | + matrix: |
| 94 | + repo: ['ansible-middleware/ansible-middleware-ee'] |
| 95 | + runs-on: ubuntu-latest |
| 96 | + steps: |
| 97 | + - name: Repository Dispatch |
| 98 | + uses: peter-evans/repository-dispatch@v1 |
| 99 | + with: |
| 100 | + token: ${{ secrets.TRIGGERING_PAT }} |
| 101 | + repository: ${{ matrix.repo }} |
| 102 | + event-type: "Dependency released - Common v${{ needs.release.outputs.tag_version }}" |
| 103 | + client-payload: '{ "github": ${{toJson(github)}} }' |
0 commit comments