Skip to content

Commit

Permalink
chore(ci): update release workflow (#143)
Browse files Browse the repository at this point in the history
  • Loading branch information
5d authored Dec 4, 2023
1 parent 92e4297 commit 4d8f83c
Show file tree
Hide file tree
Showing 3 changed files with 113 additions and 15 deletions.
48 changes: 42 additions & 6 deletions .github/workflows/deploy-pods.yml
Original file line number Diff line number Diff line change
@@ -1,21 +1,45 @@
name: Deploy Pods
on:
push:
pull_request:
types:
- closed
branches:
- release
- main

permissions:
id-token: write
contents: write
id-token: write
contents: write

jobs:
extract-release-version:
if: |
startsWith(github.head_ref, 'releases/') &&
github.event.pull_request.merged == true &&
contains(github.event.pull_request.title, 'chore: release commit for')
runs-on: ubuntu-latest
outputs:
version: ${{ steps.extract-release-version.outputs.result }}
steps:
- name: Extract release version
uses: actions/github-script@d7906e4ad0b1822421a7e6a35d5ca353c962f410 # v6.4.1
id: extract-release-version
with:
result-encoding: string
script: |
const matches = `${{ github.event.pull_request.title }}`.match(/[0-9]+\.[0-9]+\.[0-9]+/) ?? []
return matches.length > 0 ? matches[0] : ""
build-and-test:
needs: [extract-release-version]
uses: ./.github/workflows/build-and-test.yml

release:
environment: CocoaPodsRelease
needs: [build-and-test]
needs: [build-and-test, extract-release-version]
runs-on: macos-latest
steps:
env:
RELEASE_VERSION: ${{ needs.extract-release-version.outputs.version }}
steps:
- name: Checkout repo
uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0
with:
Expand Down Expand Up @@ -43,6 +67,18 @@ jobs:
bundle config set --local path $BUNDLE_PATH
bundle check || bundle install
- name: Create release tag
uses: actions/github-script@d7906e4ad0b1822421a7e6a35d5ca353c962f410 # v6.4.1
with:
script: |
github.rest.git.createRef({
owner: context.repo.owner,
repo: context.repo.repo,
ref: `refs/tags/${process.env.RELEASE_VERSION}`,
sha: context.sha,
force: true
})
- name: Release Pods
env:
COCOAPODS_SECRET_ARN: ${{ secrets.COCOAPODS_SECRET_ARN }}
Expand Down
73 changes: 68 additions & 5 deletions .github/workflows/kickoff-release.yml
Original file line number Diff line number Diff line change
@@ -1,18 +1,81 @@
name: Kickoff release

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


permissions:
id-token: write
contents: write
pull-requests: write

jobs:
prepare-release:
name: Prepare release
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 }}
needs: [validate-version-format]
env:
RELEASE_VERSION: ${{ github.event.inputs.release-version }}
runs-on: ubuntu-latest

steps:
- name: Checkout Code
uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3
with:
ref: main

- name: Restore Gems Cache
uses: actions/cache@88522ab9f39a2ea568f7027eddc7d8d8bc9d59c8 # v3.3.1
with:
path: vendor/bundle
key: app-${{ runner.os }}-gems-${{ hashFiles('**/Gemfile.lock') }}
restore-keys: |
app-${{ runner.os }}-gems-
- name: Install Bundle
env:
BUNDLE_PATH: vendor/bundle
run: |
bundle config set --local path $BUNDLE_PATH
bundle check || bundle install
- name: Bump versions to ${{ env.RELEASE_VERSION }}
run: bundle exec fastlane bump_podspecs version:$RELEASE_VERSION

- name: Create git branch with release commit
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
git config user.name aws-amplify-ops
git config user.email [email protected]
git add -A
git checkout -b releases/$RELEASE_VERSION
git commit -am "chore: release commit for $RELEASE_VERSION"
git push origin releases/$RELEASE_VERSION
shell: bash

- uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0
- name: Create PR to push main to release branch
- name: Create PR target main
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: "gh pr create --title 'chore: kickoff release' --body 'kickoff release' --head main --base release"
run: "gh pr create --title 'chore: release commit for $RELEASE_VERSION' --body 'kickoff release' --head releases/$RELEASE_VERSION --base main"
7 changes: 3 additions & 4 deletions fastlane/Fastfile
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,9 @@ pods = [

platform :ios do
desc "Bump pod versions"
lane :bump_podspecs_patch do

pods.each { |pod| version_bump_podspec(path: pod, bump_type: "patch") }

lane :bump_podspecs do |options|
next_version = options[:version].to_s
pods.each { |pod| version_bump_podspec(path: pod, version_number: "#{next_version}") }
end

desc "Release pods"
Expand Down

0 comments on commit 4d8f83c

Please sign in to comment.