Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci: add kick off release workflow [skip ci] #10

Merged
merged 1 commit into from
Aug 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions .github/scripts/bump-version.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/bin/bash

if [[ -z "${RELEASE_VERSION}" ]]; then
echo 'Environment Var RELEASE_VERSION is not defined, aborting...'
exit 1
fi

sed -E -i "s/[[:digit:]]+.[[:digit:]]+.[[:digit:]]+/${RELEASE_VERSION}/" \
$(pwd)/Sources/AWSAppSyncApolloExtensions/Utilities/PackageInfo.swift
67 changes: 67 additions & 0 deletions .github/workflows/kick-off-release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
name: Kick off release

run-name: Kick off release ${{ github.event.inputs.release-version }}

on:
workflow_dispatch:
inputs:
release-version:
description: Release version
required: true

permissions:
pull-requests: write
contents: write

jobs:
validate-version-format:
name: Validate Release Version Format
if: ${{ github.ref_name == 'main' }}
runs-on: ubuntu-latest
env:
RELEASE_VERSION: ${{ github.event.inputs.release-version }}
steps:
- name: Validate release version input
run: |
if [[ "$RELEASE_VERSION" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]
then
echo "Valid version - $RELEASE_VERSION"
else
echo "Invalid version - $RELEASE_VERSION"
exit 1
fi
shell: bash

create-release-pr:
name: Create release PR for ${{ github.event.inputs.release-version }}
runs-on: ubuntu-latest
needs:
- validate-version-format
env:
RELEASE_VERSION: ${{ github.event.inputs.release-version }}
steps:
- name: Checkout Code
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
with:
ref: main

- name: Bump versions to ${{ env.RELEASE_VERSION }}
run: |
git checkout -b bump-version/$RELEASE_VERSION main
/bin/bash ./.github/scripts/bump-version.sh
git config user.name aws-amplify-ops
git config user.email [email protected]
git add -A
git commit -am "[bump version $RELEASE_VERSION]"
git push origin HEAD
shell: bash

- name: Create Pull Request
env:
GH_TOKEN: ${{ github.token }}
run: |
gh pr create \
--title "bump version to $RELEASE_VERSION" \
--body "bump version to $RELEASE_VERSION" \
--head bump-version/$RELEASE_VERSION \
--base release