From 3cd128b550e9a9fea51268eac61eb611a91e3a2a Mon Sep 17 00:00:00 2001 From: kvelarde-itential <87794456+kvelarde-itential@users.noreply.github.com> Date: Mon, 12 Aug 2024 16:30:42 -0600 Subject: [PATCH] Update publish_ansible_collection.yml --- .../workflows/publish_ansible_collection.yml | 86 +++++++++++-------- 1 file changed, 48 insertions(+), 38 deletions(-) diff --git a/.github/workflows/publish_ansible_collection.yml b/.github/workflows/publish_ansible_collection.yml index bba9972..fbcc4e9 100644 --- a/.github/workflows/publish_ansible_collection.yml +++ b/.github/workflows/publish_ansible_collection.yml @@ -14,41 +14,51 @@ jobs: with: fetch-depth: 0 ssh-key: ${{ secrets.DEPLOY_PRIVATE_KEY }} - # - 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 }} [skip ci]" - # 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 + + - 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 }} [skip ci]" + 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 Ansible collection archive 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