|
| 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 |
0 commit comments