Skip to content

Commit b0d248b

Browse files
committed
chore: Adding worflows for automated releases
1 parent 3a2a9b0 commit b0d248b

File tree

8 files changed

+188
-4
lines changed

8 files changed

+188
-4
lines changed
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
name: Release Authenticator
2+
on:
3+
push:
4+
branches: [ release ]
5+
6+
permissions:
7+
id-token: write
8+
contents: write
9+
10+
jobs:
11+
unit-tests:
12+
name: Run Unit Tests
13+
uses: ./.github/workflows/unit_tests.yml
14+
with:
15+
identifier: 'workflow-call-unit-test'
16+
17+
release:
18+
environment: Release
19+
name: Release new Authenticator version
20+
needs: [unit-tests]
21+
runs-on: macos-latest
22+
env:
23+
GITHUB_EMAIL: aws-amplify-ops@amazon.com
24+
GITHUB_USER: aws-amplify-ops
25+
steps:
26+
- name: Configure AWS credentials
27+
uses: aws-actions/configure-aws-credentials@8c3f20df09ac63af7b3ae3d7c91f105f857d8497 #v4
28+
with:
29+
role-to-assume: ${{ secrets.AWS_ROLE_TO_ASSUME }}
30+
role-session-name: ${{ format('{0}.release', github.run_id) }}
31+
aws-region: ${{ secrets.AWS_REGION }}
32+
mask-aws-account-id: true
33+
34+
- id: retrieve-token
35+
name: Retrieve Token
36+
env:
37+
DEPLOY_SECRET_ARN: ${{ secrets.DEPLOY_SECRET_ARN }}
38+
run: |
39+
PAT=$(aws secretsmanager get-secret-value \
40+
--secret-id "$DEPLOY_SECRET_ARN" \
41+
| jq -r ".SecretString | fromjson | .Credential")
42+
echo "token=$PAT" >> $GITHUB_OUTPUT
43+
44+
- name: Checkout repo
45+
uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0
46+
with:
47+
fetch-depth: 10
48+
token: ${{steps.retrieve-token.outputs.token}}
49+
50+
- name: Setup Ruby
51+
uses: ruby/setup-ruby@250fcd6a742febb1123a77a841497ccaa8b9e939 # v1.152.0
52+
with:
53+
ruby-version: '3.2.1'
54+
bundler-cache: true
55+
56+
- name: Release Authenticator
57+
run: bundle exec fastlane release
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
name: Release - Kick-off
2+
on:
3+
workflow_dispatch:
4+
5+
permissions:
6+
pull-requests: write
7+
8+
jobs:
9+
release:
10+
name: Release
11+
runs-on: ubuntu-latest
12+
13+
steps:
14+
- uses: actions/checkout@2541b1294d2704b0964813337f33b291d3f8596b
15+
- name: Create PR to push main to release branch
16+
env:
17+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
18+
run: "gh pr create --title 'chore: kickoff release' --body 'kickoff release' --head main --base release"

.github/workflows/unit_tests.yml

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,21 +5,28 @@ on:
55
branches: [ main ]
66
pull_request:
77
branches: [ main ]
8+
workflow_call:
9+
inputs:
10+
identifier:
11+
required: true
12+
type: string
13+
14+
concurrency:
15+
group: ${{ inputs.identifier || github.workflow }}-${{ github.event.pull_request.number || github.ref }}
16+
cancel-in-progress: ${{ github.ref_name != 'main'}}
817

918
jobs:
1019
unit-test-ios:
11-
20+
name: iOS Unit Tests
1221
runs-on: macos-latest
13-
1422
steps:
1523
- uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab # v3.5.2
1624
- name: Unit test Authenticator on iOS
1725
run: xcodebuild test -scheme Authenticator -sdk 'iphonesimulator' -destination 'platform=iOS Simulator,name=iPhone 14,OS=latest' | xcpretty --simple --color --report junit && exit ${PIPESTATUS[0]}
1826

1927
unit-test-macos:
20-
28+
name: macOS Unit Tests
2129
runs-on: macos-latest
22-
2330
steps:
2431
- uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab # v3.5.2
2532
- name: Unit test Authenticator on macOS

Gemfile

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# Gemfile
2+
3+
source 'https://rubygems.org'
4+
5+
gem 'xcpretty', '0.3.0'
6+
gem 'fastlane', '2.205.1'
7+
eval_gemfile('fastlane/Pluginfile')
8+

fastlane/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
test_output

fastlane/Fastfile

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
opt_out_usage
2+
default_platform(:swift)
3+
4+
platform :swift do
5+
before_all do
6+
# Perform a fetch before inferring the next version
7+
# to reduce race conditions with simultaneous pipelines attempting to create the same tag
8+
sh('git', 'fetch', '--tags', '-f')
9+
sh('git', 'fetch')
10+
end
11+
12+
desc "Create a release version by building and committing a changelog, pushing a tag to GitHub"
13+
lane :release do
14+
next_version, commits = calculate_next_release_version
15+
16+
UI.message("Releasing version: #{next_version}")
17+
18+
# Increment all specs and plists
19+
increment_versions(version: next_version)
20+
21+
# Update Changelog
22+
changelog = build_changelog(version: next_version, commits: commits)
23+
write_changelog(changelog: changelog, path: 'CHANGELOG.md')
24+
25+
# Update Package dependencies
26+
sh('bundle', 'exec', 'swift', 'package', 'update')
27+
28+
# Commit and push
29+
release_commit(version: next_version)
30+
31+
# Create tag and push to origin
32+
add_tag(version: next_version)
33+
end
34+
35+
desc "Increment versions"
36+
private_lane :increment_versions do |options|
37+
version = options[:version].to_s
38+
set_key_value(file: "Sources/Authenticator/Constants/ComponentInformation.swift", key: "version", value: version)
39+
end
40+
41+
desc "Commit and push"
42+
private_lane :release_commit do |options|
43+
next_version = options[:version]
44+
45+
sh('git', 'config', '--global', 'user.email', ENV['GITHUB_EMAIL'])
46+
sh('git', 'config', '--global', 'user.name', ENV['GITHUB_USER'])
47+
48+
commit_message = "chore: Release #{next_version} [skip ci]"
49+
sh('git', 'commit', '-am', commit_message)
50+
51+
# push to origin
52+
sh('git', 'push', 'origin', 'release')
53+
sh('git', 'push', 'origin', 'release:main')
54+
end
55+
56+
desc "Tag in git and push to GitHub"
57+
private_lane :add_tag do |options|
58+
next_version = options[:version]
59+
next_tag = "#{next_version}"
60+
61+
add_git_tag(tag: next_tag)
62+
push_git_tags(tag: next_tag)
63+
end
64+
end

fastlane/Pluginfile

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Autogenerated by fastlane
2+
#
3+
# Ensure this file is checked in to source control!
4+
5+
gem 'fastlane-plugin-release_actions', git: 'https://github.com/aws-amplify/amplify-ci-support', branch: 'main', glob: 'src/fastlane/release_actions/*.gemspec'

fastlane/README.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
fastlane documentation
2+
----
3+
4+
# Installation
5+
6+
Make sure you have the latest version of the Xcode command line tools installed:
7+
8+
```sh
9+
xcode-select --install
10+
```
11+
12+
For _fastlane_ installation instructions, see [Installing _fastlane_](https://docs.fastlane.tools/#installing-fastlane)
13+
14+
# Available Actions
15+
16+
## Swift
17+
18+
### swift release
19+
20+
```sh
21+
[bundle exec] fastlane swift release
22+
```
23+
24+
Create a release version by building and committing a changelog, pushing a tag to GitHub

0 commit comments

Comments
 (0)