Update module github.com/giantswarm/versionbundle to v1 #36
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 release | |
on: | |
pull_request: | |
types: [closed] | |
jobs: | |
delete_draft_release: | |
if: github.event_name == 'pull_request' && github.event.action == 'closed' | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v2 | |
with: | |
fetch-depth: '0' | |
- name: Delete draft releases and tags | |
env: | |
GITHUB_TOKEN: "${{ secrets.TAYLORBOT_GITHUB_ACTION }}" | |
run: | | |
for provider_dir in capa/* azure/*; do | |
provider="" | |
if [[ $provider_dir == capa/* ]]; then | |
provider="aws" | |
elif [[ $provider_dir == azure/* ]]; then | |
provider="azure" | |
fi | |
if [[ -f $provider_dir || -z $provider ]]; then | |
echo "Skipping file or unknown provider $provider_dir" | |
continue | |
fi | |
release_version="$(basename $provider_dir)" | |
draft_tag_name="draft/$provider/$release_version" | |
draft_release=$(gh release --repo giantswarm/releases view "$draft_tag_name" --json "id,name,tagName,assets,isDraft,isPrerelease,url" 2>&1 || true) | |
if [ "$draft_release" = "release not found" ]; then | |
echo "Draft release not found for tag $draft_tag_name" | |
else | |
echo "Found existing draft release $draft_tag_name, will delete it." | |
gh release delete --repo giantswarm/releases "$draft_tag_name" --yes --cleanup-tag | |
fi | |
done | |
create_release: | |
if: github.event.pull_request.merged == true | |
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 new release tag | |
run: | | |
git fetch --tags | |
for provider_dir in capa/* capz/*; do | |
provider="" | |
if [[ $provider_dir == capa/* ]]; then | |
provider="aws" | |
elif [[ $provider_dir == azure/* ]]; then | |
provider="azure" | |
fi | |
if [[ -f $provider_dir || -z $provider ]]; then | |
echo "Skipping file or unknown provider $provider_dir" | |
continue | |
fi | |
release_version="$(basename $provider_dir)" | |
echo "Found $provider release $release_version." | |
tag_name="$provider/$release_version" | |
if [ $(git tag -l "$tag_name") ]; then | |
echo "Found existing tag $tag_name for release version $release_version, new tag is not needed." | |
else | |
echo "Tag $tag_name for release version $release_version not found, will create it." | |
tag_message="Workload cluster release $release_version for $provider" | |
git tag -a "$tag_name" -m "$tag_message" | |
git push origin "$tag_name" | |
fi | |
done | |
- name: Create new GitHub release | |
env: | |
GITHUB_TOKEN: "${{ secrets.TAYLORBOT_GITHUB_ACTION }}" | |
run: | | |
for provider_dir in capa/* azure/*; do | |
provider="" | |
if [[ $provider_dir == capa/* ]]; then | |
provider="aws" | |
elif [[ $provider_dir == azure/* ]]; then | |
provider="azure" | |
fi | |
if [[ -f $provider_dir || -z $provider ]]; then | |
echo "Skipping file or unknown provider $provider_dir" | |
continue | |
fi | |
release_version="$(basename $provider_dir)" | |
tag_name="$provider/$release_version" | |
github_release=$(gh release --repo giantswarm/releases view "$tag_name" --json "id,name,tagName,assets,isDraft,isPrerelease,url" 2>&1 || true) | |
current_commit="$(git rev-parse HEAD)" | |
release_title="Workload cluster release $release_version for $provider" | |
release_note="This release has been created automatically by GitHub action. CI will be updated to have better release notes here." | |
if [ "$github_release" = "release not found" ]; then | |
echo "Didn't find a GitHub release for release version $release_version and tag $tag_name. Creating a new release." | |
if [[ $release_version == *-* ]]; then | |
gh release create --repo giantswarm/releases --target "$current_commit" --title "$release_title" --notes "$release_note" "$tag_name" "$provider_dir/release.yaml" --prerelease | |
else | |
gh release create --repo giantswarm/releases --target "$current_commit" --title "$release_title" --notes "$release_note" "$tag_name" "$provider_dir/release.yaml" | |
fi | |
else | |
echo "Found existing GitHub release for release version $release_version and tag $tag_name." | |
fi | |
done |