Skip to content

Commit d0f8360

Browse files
committed
chore: refactoring to avoid release branch
1 parent 9f0cd72 commit d0f8360

File tree

3 files changed

+94
-24
lines changed

3 files changed

+94
-24
lines changed

.github/workflows/release_authenticator.yml

Lines changed: 28 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,48 @@
11
name: Release Authenticator
22
on:
33
push:
4-
branches: [ release ]
4+
branches: [ ruisebas/main ]
55

66
permissions:
77
id-token: write
88
contents: write
99

1010
jobs:
11+
determine-next-version:
12+
name: Determine the next release version
13+
runs-on: ubuntu-latest
14+
outputs:
15+
version: ${{ steps.extract-release-version.outputs.result }}
16+
if: "${{ github.event.head_commit.author == 'aws-amplify-ops' && startsWith(github.event.head_commit.message, 'chore: Release ') }}"
17+
steps:
18+
- name: Extract release version
19+
uses: actions/github-script@d7906e4ad0b1822421a7e6a35d5ca353c962f410 # v6.4.1
20+
id: extract-release-version
21+
with:
22+
result-encoding: string
23+
script: |
24+
const matches = `${{ github.event.head_commit.message }}`.match(/[0-9]+\.[0-9]+\.[0-9]+/) ?? []
25+
return matches.length > 0 ? matches[0] : ""
26+
27+
validate-version-format:
28+
name: Validate Version Format
29+
needs: [determine-next-version]
30+
if: ${{ needs.determine-next-version.outputs.version != '' }}
31+
runs-on: ubuntu-latest
32+
steps:
33+
- run: echo "Releasing new version ${{ needs.determine-next-version.outputs.version }}"
34+
1135
unit-tests:
1236
name: Run Unit Tests
37+
needs: [validate-version-format]
1338
uses: ./.github/workflows/unit_tests.yml
1439
with:
1540
identifier: 'workflow-call-unit-test'
1641

1742
release:
1843
environment: Release
1944
name: Release new Authenticator version
20-
needs: [unit-tests]
45+
needs: [unit-tests, determine-next-version]
2146
runs-on: macos-latest
2247
env:
2348
GITHUB_EMAIL: [email protected]
@@ -54,4 +79,4 @@ jobs:
5479
bundler-cache: true
5580

5681
- name: Release Authenticator
57-
run: bundle exec fastlane release
82+
run: bundle exec fastlane perform_release version:${{ needs.determine-next-version.outputs.version }}
Lines changed: 39 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,50 @@
11
name: Release - Kick-off
22
on:
33
workflow_dispatch:
4+
push:
5+
branches: [ dev ]
46

57
permissions:
68
pull-requests: write
79

810
jobs:
911
release:
10-
name: Release
11-
runs-on: ubuntu-latest
12-
12+
environment: Release
13+
name: Kick off new Authenticator release
14+
runs-on: macos-latest
15+
env:
16+
GITHUB_EMAIL: [email protected]
17+
GITHUB_USER: aws-amplify-ops
1318
steps:
14-
- uses: actions/checkout@2541b1294d2704b0964813337f33b291d3f8596b
15-
- name: Create PR to push main to release branch
19+
- name: Configure AWS credentials
20+
uses: aws-actions/configure-aws-credentials@8c3f20df09ac63af7b3ae3d7c91f105f857d8497 #v4
21+
with:
22+
role-to-assume: ${{ secrets.AWS_ROLE_TO_ASSUME }}
23+
role-session-name: ${{ format('{0}.release', github.run_id) }}
24+
aws-region: ${{ secrets.AWS_REGION }}
25+
mask-aws-account-id: true
26+
27+
- id: retrieve-token
28+
name: Retrieve Token
1629
env:
17-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
18-
run: "gh pr create --title 'chore: kickoff release' --body 'kickoff release' --head main --base release"
30+
DEPLOY_SECRET_ARN: ${{ secrets.DEPLOY_SECRET_ARN }}
31+
run: |
32+
PAT=$(aws secretsmanager get-secret-value \
33+
--secret-id "$DEPLOY_SECRET_ARN" \
34+
| jq -r ".SecretString | fromjson | .Credential")
35+
echo "token=$PAT" >> $GITHUB_OUTPUT
36+
37+
- name: Checkout repo
38+
uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0
39+
with:
40+
fetch-depth: 10
41+
token: ${{steps.retrieve-token.outputs.token}}
42+
43+
- name: Setup Ruby
44+
uses: ruby/setup-ruby@22fdc77bf4148f810455b226c90fb81b5cbc00a7 # v1.171.0
45+
with:
46+
ruby-version: '3.2.1'
47+
bundler-cache: true
48+
49+
- name: Kick off Authenticator release
50+
run: bundle exec fastlane prepare_release

fastlane/Fastfile

Lines changed: 27 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,11 @@ platform :swift do
99
sh('git', 'fetch')
1010
end
1111

12-
desc "Create a release version by building and committing a changelog, pushing a tag to GitHub"
13-
lane :release do
12+
desc "Preparing next release by building and committing a changelog, updating the component version, and creating a PR to main"
13+
lane :prepare_release do
1414
next_version, commits = calculate_next_release_version
1515

16-
UI.message("Releasing version: #{next_version}")
17-
16+
UI.message("Kicking off new release for version: #{next_version}")
1817
# Increment all specs and plists
1918
increment_versions(version: next_version)
2019

@@ -25,11 +24,17 @@ platform :swift do
2524
# Update Package dependencies
2625
sh('bundle', 'exec', 'swift', 'package', 'update')
2726

27+
# Create and push the new branch
28+
release_branch = "release/#{next_version}"
29+
sh('git', 'checkout', '-b', release_branch)
30+
sh('git', 'push', '--set-upstream', 'origin', release_branch)
31+
2832
# Commit and push
2933
release_commit(version: next_version)
3034

31-
# Create tag and push to origin
32-
add_tag(version: next_version)
35+
# Open the PR to main
36+
#pr_title = "chore: Release #{next_version}"
37+
sh('gh', 'pr', 'create', '--head', 'main')
3338
end
3439

3540
desc "Increment versions"
@@ -45,20 +50,28 @@ platform :swift do
4550
sh('git', 'config', '--global', 'user.email', ENV['GITHUB_EMAIL'])
4651
sh('git', 'config', '--global', 'user.name', ENV['GITHUB_USER'])
4752

48-
commit_message = "chore: Release #{next_version} [skip ci]"
53+
commit_message = "chore: Release #{next_version}"
4954
sh('git', 'commit', '-am', commit_message)
55+
sh('git', 'push')
56+
end
5057

51-
# push to origin
52-
sh('git', 'push', 'origin', 'release')
53-
sh('git', 'push', 'origin', 'release:main')
58+
desc "Push a new tag to GitHub and creating a new draft release"
59+
lane :perform_release do |options|
60+
next_version = options[:version]
61+
# Create and push the new tag
62+
add_tag(version: next_version)
63+
64+
# Create draft release
65+
release_title = sh("echo $(date +%F)")
66+
sh('gh', 'release', 'create', '--draft', '--verify-tag', '--title', release_title)
5467
end
5568

5669
desc "Tag in git and push to GitHub"
5770
private_lane :add_tag do |options|
58-
next_version = options[:version]
59-
next_tag = "#{next_version}"
71+
next_tag = options[:version].to_s
6072

61-
add_git_tag(tag: next_tag)
62-
push_git_tags(tag: next_tag)
73+
puts "Creating new tag #{next_tag}"...
74+
#add_git_tag(tag: next_tag)
75+
#push_git_tags(tag: next_tag)
6376
end
6477
end

0 commit comments

Comments
 (0)