mirror of
https://github.com/ansible/awx.git
synced 2026-01-10 15:32:07 -03:30
115 lines
4.1 KiB
YAML
115 lines
4.1 KiB
YAML
---
|
|
name: Promote Release
|
|
|
|
env:
|
|
LC_ALL: "C.UTF-8" # prevent ERROR: Ansible could not initialize the preferred locale: unsupported locale setting
|
|
|
|
on:
|
|
release:
|
|
types: [published]
|
|
workflow_dispatch:
|
|
inputs:
|
|
tag_name:
|
|
description: 'Name for the tag of the release.'
|
|
required: true
|
|
permissions:
|
|
contents: read # to fetch code (actions/checkout)
|
|
|
|
jobs:
|
|
promote:
|
|
if: endsWith(github.repository, '/awx')
|
|
runs-on: ubuntu-latest
|
|
timeout-minutes: 90
|
|
steps:
|
|
- name: Set GitHub Env vars for workflow_dispatch event
|
|
if: ${{ github.event_name == 'workflow_dispatch' }}
|
|
run: |
|
|
echo "TAG_NAME=${{ github.event.inputs.tag_name }}" >> $GITHUB_ENV
|
|
|
|
- name: Set GitHub Env vars if release event
|
|
if: ${{ github.event_name == 'release' }}
|
|
run: |
|
|
echo "TAG_NAME=${{ github.event.release.tag_name }}" >> $GITHUB_ENV
|
|
|
|
- name: Checkout awx
|
|
uses: actions/checkout@v4
|
|
with:
|
|
show-progress: false
|
|
|
|
- uses: ./.github/actions/setup-python
|
|
|
|
- name: Install dependencies
|
|
run: |
|
|
python${{ env.py_version }} -m pip install wheel twine setuptools-scm
|
|
|
|
- name: Set official collection namespace
|
|
run: echo collection_namespace=awx >> $GITHUB_ENV
|
|
if: ${{ github.repository_owner == 'ansible' }}
|
|
|
|
- name: Set unofficial collection namespace
|
|
run: echo collection_namespace=${{ github.repository_owner }} >> $GITHUB_ENV
|
|
if: ${{ github.repository_owner != 'ansible' }}
|
|
|
|
- name: Build collection and publish to galaxy
|
|
env:
|
|
COLLECTION_NAMESPACE: ${{ env.collection_namespace }}
|
|
COLLECTION_VERSION: ${{ env.TAG_NAME }}
|
|
COLLECTION_TEMPLATE_VERSION: true
|
|
run: |
|
|
sudo apt-get install jq
|
|
make build_collection
|
|
count=$(curl -s https://galaxy.ansible.com/api/v3/plugin/ansible/search/collection-versions/\?namespace\=${COLLECTION_NAMESPACE}\&name\=awx\&version\=${COLLECTION_VERSION} | jq .meta.count)
|
|
if [[ "$count" == "1" ]]; then
|
|
echo "Galaxy release already done";
|
|
elif [[ "$count" == "0" ]]; then
|
|
ansible-galaxy collection publish \
|
|
--token=${{ secrets.GALAXY_TOKEN }} \
|
|
awx_collection_build/${COLLECTION_NAMESPACE}-awx-${COLLECTION_VERSION}.tar.gz;
|
|
else
|
|
echo "Unexpected count from galaxy search: $count";
|
|
exit 1;
|
|
fi
|
|
|
|
- name: Set official pypi info
|
|
run: echo pypi_repo=pypi >> $GITHUB_ENV
|
|
if: ${{ github.repository_owner == 'ansible' }}
|
|
|
|
- name: Set unofficial pypi info
|
|
run: echo pypi_repo=testpypi >> $GITHUB_ENV
|
|
if: ${{ github.repository_owner != 'ansible' }}
|
|
|
|
- name: Build awxkit and upload to pypi
|
|
env:
|
|
SETUPTOOLS_SCM_PRETEND_VERSION: ${{ env.TAG_NAME }}
|
|
run: |
|
|
git reset --hard
|
|
cd awxkit && python3 setup.py sdist bdist_wheel
|
|
twine upload \
|
|
-r ${{ env.pypi_repo }} \
|
|
-u ${{ secrets.PYPI_USERNAME }} \
|
|
-p ${{ secrets.PYPI_PASSWORD }} \
|
|
dist/*
|
|
|
|
- name: Log in to GHCR
|
|
run: |
|
|
echo ${{ secrets.GITHUB_TOKEN }} | docker login ghcr.io -u ${{ github.actor }} --password-stdin
|
|
|
|
- name: Log in to Quay
|
|
run: |
|
|
echo ${{ secrets.QUAY_TOKEN }} | docker login quay.io -u ${{ secrets.QUAY_USER }} --password-stdin
|
|
|
|
- name: Re-tag and promote awx image
|
|
run: |
|
|
docker buildx imagetools create \
|
|
ghcr.io/${{ github.repository }}:${{ env.TAG_NAME }} \
|
|
--tag quay.io/${{ github.repository }}:${{ env.TAG_NAME }}
|
|
docker buildx imagetools create \
|
|
ghcr.io/${{ github.repository }}:${{ env.TAG_NAME }} \
|
|
--tag quay.io/${{ github.repository }}:latest
|
|
|
|
- name: Re-tag and promote awx-ee image
|
|
run: |
|
|
docker buildx imagetools create \
|
|
ghcr.io/${{ github.repository_owner }}/awx-ee:${{ env.TAG_NAME }} \
|
|
--tag quay.io/${{ github.repository_owner }}/awx-ee:${{ env.TAG_NAME }}
|