2022-03-01 18:05:28 +00:00
|
|
|
---
|
2021-12-14 08:54:49 +00:00
|
|
|
name: Release collection
|
|
|
|
on:
|
2022-03-31 12:56:41 +00:00
|
|
|
workflow_dispatch:
|
2021-12-14 08:54:49 +00:00
|
|
|
|
|
|
|
jobs:
|
|
|
|
release:
|
|
|
|
runs-on: ubuntu-latest
|
2022-03-31 12:56:41 +00:00
|
|
|
if: github.repository == 'ansible-middleware/keycloak'
|
|
|
|
permissions:
|
|
|
|
actions: write
|
|
|
|
checks: write
|
|
|
|
contents: write
|
|
|
|
deployments: write
|
|
|
|
packages: write
|
|
|
|
pages: write
|
2021-12-14 08:54:49 +00:00
|
|
|
steps:
|
2022-01-27 10:59:10 +00:00
|
|
|
- name: Checkout code
|
2022-04-01 10:14:09 +00:00
|
|
|
uses: actions/checkout@v3
|
|
|
|
with:
|
|
|
|
fetch-depth: 0
|
2022-03-31 14:51:25 +00:00
|
|
|
|
2021-12-14 08:54:49 +00:00
|
|
|
- name: Set up Python
|
|
|
|
uses: actions/setup-python@v1
|
|
|
|
with:
|
|
|
|
python-version: "3.x"
|
2022-03-31 14:51:25 +00:00
|
|
|
|
2022-03-31 12:56:41 +00:00
|
|
|
- name: Get current version
|
2021-12-14 08:54:49 +00:00
|
|
|
id: get_version
|
2022-03-31 12:56:41 +00:00
|
|
|
run: echo "::set-output name=TAG_VERSION::$(grep version galaxy.yml | awk -F'"' '{ print $2 }')"
|
2022-03-31 14:51:25 +00:00
|
|
|
|
2022-03-31 12:56:41 +00:00
|
|
|
- name: Check if tag exists
|
|
|
|
id: check_tag
|
|
|
|
run: echo "::set-output name=TAG_EXISTS::$(git tag | grep ${{ steps.get_version.outputs.TAG_VERSION }})"
|
2022-03-31 14:51:25 +00:00
|
|
|
|
2022-03-31 12:56:41 +00:00
|
|
|
- name: Fail if tag exists
|
|
|
|
if: ${{ steps.get_version.outputs.TAG_VERSION == steps.check_tag.outputs.TAG_EXISTS }}
|
|
|
|
uses: actions/github-script@v3
|
|
|
|
with:
|
|
|
|
script: |
|
|
|
|
core.setFailed('Release tag already exists')
|
2022-03-31 14:51:25 +00:00
|
|
|
|
2021-12-14 08:54:49 +00:00
|
|
|
- name: Install dependencies
|
|
|
|
run: |
|
|
|
|
python -m pip install --upgrade pip
|
2022-03-31 13:54:30 +00:00
|
|
|
pip install ansible-core antsibull
|
2022-03-31 12:56:41 +00:00
|
|
|
sudo apt install -y sed hub
|
2022-03-31 14:51:25 +00:00
|
|
|
|
2021-12-14 08:54:49 +00:00
|
|
|
- name: Build collection
|
|
|
|
run: |
|
|
|
|
ansible-galaxy collection build .
|
2022-03-31 14:51:25 +00:00
|
|
|
|
2022-03-31 12:56:41 +00:00
|
|
|
- name: Scan PR merges from latest tag
|
|
|
|
run: |
|
2022-03-31 13:54:30 +00:00
|
|
|
TYPES=("minor_changes" "major_changes" "bugfixes" "deprecated_features" "removed_features" "breaking_changes")
|
2022-03-31 12:56:41 +00:00
|
|
|
TAG=$(git describe --abbrev=0 --tags)
|
|
|
|
PRS=($(comm -12 <(git log --oneline ${TAG}.. --format="tformat:%H" | sort ) <(hub pr list -s all -f '%sm%n' --color=never | sort )))
|
|
|
|
IFS=$'\n' FRAGMENTS=($(hub pr list -s all -f '%sm~%I~%L~%t~%n' --color=never| grep -P "$(echo "^(${PRS[@]})" | tr ' ' '|')"))
|
|
|
|
for frag in "${FRAGMENTS[@]}"; do
|
|
|
|
PR=$(echo $frag|cut -d~ -f2)
|
|
|
|
type="$(echo $frag|cut -d~ -f3)"
|
|
|
|
msg="$(echo $frag|cut -d~ -f4|sed 's/`/``/g')"
|
2022-04-01 19:41:52 +00:00
|
|
|
if [[ "$type" != "" && "${TYPES[*]}" =~ "${type}" ]]; then
|
2022-04-01 10:53:56 +00:00
|
|
|
echo -e "$type:\n - >\n $msg \`#${PR} <https://github.com/ansible-middleware/keycloak/pull/${PR}>\`_" \
|
2022-03-31 12:56:41 +00:00
|
|
|
> changelogs/fragments/${PR}.yaml
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
antsibull-changelog lint -vvv
|
|
|
|
antsibull-changelog generate
|
|
|
|
antsibull-changelog release
|
2021-12-14 08:54:49 +00:00
|
|
|
env:
|
|
|
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
2022-03-31 14:51:25 +00:00
|
|
|
|
2022-03-31 12:56:41 +00:00
|
|
|
- name: Commit changelogs
|
|
|
|
run: |
|
|
|
|
git config user.name github-actions
|
|
|
|
git config user.email github-actions@github.com
|
2022-04-01 08:57:42 +00:00
|
|
|
git diff --minimal --output-indicator-new=' ' -U0 --no-indent-heuristic CHANGELOG.rst | grep "^ "| sed -e 's/`\(#[0-9]\+\) <.*_/\1/g' > gh-release.md
|
2022-03-31 12:56:41 +00:00
|
|
|
git add CHANGELOG.rst changelogs/changelog.yaml
|
|
|
|
git commit -m "Update changelog for release ${{ steps.get_version.outputs.TAG_VERSION }}" || true
|
|
|
|
git push origin
|
2022-03-31 14:51:25 +00:00
|
|
|
|
2021-12-14 08:54:49 +00:00
|
|
|
- name: Publish collection
|
|
|
|
env:
|
|
|
|
ANSIBLE_GALAXY_API_KEY: ${{ secrets.ANSIBLE_GALAXY_API_KEY }}
|
|
|
|
run: |
|
2022-01-27 10:59:10 +00:00
|
|
|
ansible-galaxy collection publish *.tar.gz --api-key $ANSIBLE_GALAXY_API_KEY
|
2022-03-31 14:51:25 +00:00
|
|
|
|
2022-03-31 12:56:41 +00:00
|
|
|
- name: Create release tag
|
|
|
|
run: |
|
|
|
|
git config user.name github-actions
|
|
|
|
git config user.email github-actions@github.com
|
2022-04-01 11:06:34 +00:00
|
|
|
git tag -a ${{ steps.get_version.outputs.TAG_VERSION }} -m "Release v${{ steps.get_version.outputs.TAG_VERSION }}" || true
|
2022-03-31 12:56:41 +00:00
|
|
|
git push origin --tags
|
2022-03-31 14:51:25 +00:00
|
|
|
|
2022-03-31 12:56:41 +00:00
|
|
|
- name: Publish Release
|
|
|
|
uses: softprops/action-gh-release@v1
|
|
|
|
env:
|
|
|
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
|
|
with:
|
2022-04-01 08:57:42 +00:00
|
|
|
tag_name: ${{ steps.get_version.outputs.TAG_VERSION }}
|
2022-03-31 12:56:41 +00:00
|
|
|
files: "*.tar.gz"
|
2022-04-01 08:57:42 +00:00
|
|
|
body_path: gh-release.md
|
2022-03-31 14:51:25 +00:00
|
|
|
|
2022-01-27 11:00:11 +00:00
|
|
|
dispatch:
|
2022-01-27 10:59:10 +00:00
|
|
|
needs: release
|
|
|
|
strategy:
|
|
|
|
matrix:
|
2022-03-23 14:42:41 +00:00
|
|
|
repo: ['ansible-middleware/cross-dc-rhsso-demo', 'ansible-middleware/flange-demo', 'ansible-middleware/ansible-middleware-ee']
|
2022-01-27 10:59:10 +00:00
|
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
|
|
|
- name: Repository Dispatch
|
|
|
|
uses: peter-evans/repository-dispatch@v1
|
|
|
|
with:
|
|
|
|
token: ${{ secrets.TRIGGERING_PAT }}
|
|
|
|
repository: ${{ matrix.repo }}
|
2022-03-31 12:56:41 +00:00
|
|
|
event-type: "Dependency released - Keycloak v${{ steps.get_version.outputs.TAG_VERSION }}"
|
2022-01-27 10:59:10 +00:00
|
|
|
client-payload: '{ "github": ${{toJson(github)}} }'
|