Adding CAPA v25.1.0 minor release #352
Workflow file for this run
This file contains 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: Create GitHub draft release | |
on: | |
push: | |
branches: | |
- master | |
pull_request: | |
branches: | |
- master | |
jobs: | |
create_draft_release: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v2 | |
with: | |
fetch-depth: '0' | |
fetch-tags: 'true' | |
- name: Set up git identity | |
run: | | |
git config --local user.email "[email protected]" | |
git config --local user.name "taylorbot" | |
- name: Create or update draft release tags | |
run: | | |
git fetch --tags | |
for aws_release_dir in capa/*; do | |
if [[ -f $aws_release_dir ]]; then | |
echo "Skipping file $aws_release_dir" | |
continue | |
fi | |
aws_release_version="$(basename $aws_release_dir)" | |
echo "Found AWS release $aws_release_version" | |
draft_tag_name="draft/aws/$aws_release_version" | |
if [ $(git tag -l "$draft_tag_name") ]; then | |
echo "Found existing tag $draft_tag_name, will force-overwrite it" | |
# Delete origin tag | |
git push --delete origin "$draft_tag_name" | |
# Create new tag locally | |
git tag -fa "$draft_tag_name" -m "AWS draft release $aws_release_version" | |
git push -f origin "$draft_tag_name" | |
else | |
echo "Tag $draft_tag_name not found" | |
published_tag_name="aws/$aws_release_version" | |
published_release=$(gh release --repo giantswarm/releases view "$published_tag_name" --json "id,name,tagName,assets,isDraft,isPrerelease,url" 2>&1 || true) | |
if [ "$published_release" = "release not found" ]; then | |
echo "Didn't find a release for neither published tag $published_tag_name nor for tag $draft_tag_name. Will create a new draft tag." | |
git tag -a "$draft_tag_name" -m "AWS (CAPA) draft release $aws_release_version" | |
git push -f origin "$draft_tag_name" | |
else | |
echo "Found a published release with tag $published_tag_name. Skipping draft tag creation." | |
fi | |
fi | |
done | |
- name: Create or update draft releases | |
env: | |
GITHUB_TOKEN: "${{ secrets.TAYLORBOT_GITHUB_ACTION }}" | |
BRANCH: ${{ github.head_ref }} | |
run: | | |
for aws_release_dir in capa/*; do | |
if [[ -f $aws_release_dir ]]; then | |
echo "Skipping file $aws_release_dir" | |
continue | |
fi | |
aws_release_version="$(basename $aws_release_dir)" | |
draft_tag_name="draft/aws/$aws_release_version" | |
draft_release=$(gh release --repo giantswarm/releases view "$draft_tag_name" --json "id,name,tagName,assets,isDraft,isPrerelease,url" 2>&1 || true) | |
current_commit="$(git rev-parse HEAD)" | |
release_title="Draft workload cluster release $aws_release_version for AWS (CAPA)" | |
pr_number="$(gh pr view "$BRANCH" --json "number" --jq ".number")" | |
release_note="DO NOT USE FOR PRODUCTION PURPOSES. See PR #${pr_number} for more details. This draft release has been created automatically by GitHub action. It will be deleted when the PR is merged." | |
if [ "$draft_release" = "release not found" ]; then | |
published_tag_name="aws/$aws_release_version" | |
published_release=$(gh release --repo giantswarm/releases view "$published_tag_name" --json "id,name,tagName,assets,isDraft,isPrerelease,url" 2>&1 || true) | |
if [ "$published_release" = "release not found" ]; then | |
echo "Didn't find a release for neither published tag $published_tag_name nor for tag $draft_tag_name. Will create a new draft release." | |
gh release create --repo giantswarm/releases --draft --target "$current_commit" --title "$release_title" --notes "$release_note" "$draft_tag_name" "$aws_release_dir/release.yaml" | |
else | |
echo "Found a published release with tag $published_tag_name. Skipping draft release creation." | |
fi | |
else | |
echo "Found existing draft release $draft_tag_name, will update it." | |
gh release edit --repo giantswarm/releases --draft --target "$current_commit" --title "$release_title" --notes "$release_note" "$draft_tag_name" | |
gh release upload --repo giantswarm/releases --clobber "$draft_tag_name" "$aws_release_dir/release.yaml" | |
fi | |
done |