Skip to content

Commit 81aeec6

Browse files
ci: Full deployment automation (#685)
* update deployment script * add empty changelog * add variables to deploy lane * add generate_changelog script
1 parent 71d159e commit 81aeec6

File tree

3 files changed

+73
-27
lines changed

3 files changed

+73
-27
lines changed

CHANGELOG.md

Whitespace-only changes.

fastlane/Fastfile

Lines changed: 41 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -45,52 +45,66 @@ end
4545
desc "Available options: type:major|minor|patch"
4646
lane :deploy do |options|
4747

48-
branch = options[:branch] || "master"
49-
prepare_git(branch)
48+
repository_name = "algolia/algoliasearch-client-swift"
49+
podspec_path = "AlgoliaSearchClient.podspec"
50+
base_branch = options[:branch] || "master"
5051

51-
pod_lib_lint(
52-
verbose: true,
53-
allow_warnings: true
52+
ensure_git_branch(
53+
branch: base_branch
5454
)
55+
ensure_git_status_clean
5556

56-
new_build_number = version_bump_podspec(
57-
bump_type: options[:type],
58-
path: "AlgoliaSearchClient.podspec"
57+
release_type = options[:type]
58+
59+
new_version = version_bump_podspec(
60+
bump_type: release_type,
61+
path: podspec_path
5962
)
6063

61-
sh("cd ..; ./generate_version #{new_build_number}")
64+
sh("cd ..; ./generate_changelog #{new_version}")
65+
sh("cd ..; ./generate_version #{new_version}")
6266

63-
branchName = "version-#{new_build_number}"
64-
sh("git checkout -b #{branchName}")
67+
branch_name = "version-#{new_version}"
68+
sh("git checkout -b #{branch_name}")
6569

66-
#puts changelog_from_git_commits
6770
git_commit(
68-
path: ["AlgoliaSearchClient.podspec", "./Sources/AlgoliaSearchClient/Helpers/Version+Current.swift"],
69-
message: "Version #{new_build_number}"
71+
path: [podspec_path, "./Sources/AlgoliaSearchClient/Helpers/Version+Current.swift", "CHANGELOG.md"],
72+
message: "chore: update version to #{new_version} [skip ci]"
7073
)
7174
add_git_tag(
72-
build_number: new_build_number,
73-
tag: new_build_number
75+
build_number: new_version,
76+
tag: new_version
7477
)
7578
push_to_git_remote(remote: "origin")
7679

7780
create_pull_request(
78-
# api_token: "secret", # optional, defaults to ENV["GITHUB_API_TOKEN"]
79-
repo: "algolia/algoliasearch-client-swift",
80-
title: "Deploying new #{options[:type]} version #{new_build_number}",
81-
head: "#{branchName}", # optional, defaults to current branch name
82-
base: "master", # optional, defaults to "master"
83-
body: "Please check the files before merging in case I've overidden something accidentally.", # optional
84-
# api_url: "http://yourdomain/api/v3" # optional, for GitHub Enterprise, defaults to "https://api.github.com"
81+
repo: repository_name,
82+
title: "chore: Deploying new #{release_type} version #{new_version}",
83+
head: branch_name,
84+
base: base_branch,
85+
body: "Please check the files before merging in case I've overidden something accidentally."
86+
)
87+
88+
set_github_release(
89+
repository_name: repository_name,
90+
api_token: ENV["GITHUB_API_TOKEN"],
91+
name: new_version,
92+
tag_name: new_version,
93+
description: (File.read("../release_notes.md") rescue "No release notes provided"),
94+
is_draft: true,
95+
commitish: base_branch,
96+
upload_assets: []
8597
)
8698

99+
# Remove deployment trigger tag if needed
100+
if git_tag_exists(tag: "#{release_type}")
101+
sh("git tag -d #{release_type}; git push --delete origin #{release_type}")
102+
end
103+
87104
pod_push(
88-
path: "AlgoliaSearchClient.podspec",
105+
path: podspec_path,
89106
allow_warnings: true
90107
)
91-
# This is failing when no files are changed. So we added this step in Bitrise instead along with is_skippable: true.
92-
#
93-
# deploy_api_reference
94108
end
95109

96110
lane :deployBeta do |options|

generate_changelog

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# This script updates the CHANGELOG.md using Polyglot script
2+
# and generates diff changelog with latest changes to use in release notes
3+
4+
# Check if polyglot installed
5+
if ! command -v polyglot &> /dev/null
6+
then
7+
echo "Polyglot tool could not be found. Install 'algolia/polyglot' first."
8+
exit 1
9+
fi
10+
11+
# Check version number parameter
12+
version_number=$1
13+
if [ -z "${version_number}" ]
14+
then
15+
echo >&2 "Missing version number parameter"
16+
exit 1
17+
fi
18+
19+
# Backup previous changelog
20+
mv CHANGELOG.md CHANGELOG_backup.md
21+
22+
# Generate the changelog for changes since last tag to extract release notes
23+
polyglot changelog $version_number
24+
25+
# Cut unnecessary first 5 lines of generated release notes
26+
cat CHANGELOG.md | tail -n +5 | cat > release_notes.md
27+
28+
# Restore previous changelog
29+
mv CHANGELOG_backup.md CHANGELOG.md
30+
31+
# Update changelog
32+
polyglot changelog $version_number

0 commit comments

Comments
 (0)