-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
7823872
commit fa79d73
Showing
2 changed files
with
95 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
class String | ||
def colorize(color_code) | ||
"\e[38;5;#{color_code}m#{self}\e[0m" | ||
end | ||
end | ||
|
||
BUMP_TYPE = ARGV[0] | ||
unless /^(major|minor|patch)$/.match?(BUMP_TYPE) | ||
abort("Please, pass one of these major/minor/patch bump type.".colorize(9)) | ||
end | ||
|
||
VERSION = %x[grep -Eo '[0-9]+.[0-9]+.[0-9]+' Sources/Pods/main.swift].chomp | ||
VERSION_PARTS = VERSION.split(".").map(&:to_i) | ||
|
||
if BUMP_TYPE == "major" | ||
VERSION_PARTS[0] += 1 | ||
VERSION_PARTS[1] = 0 | ||
VERSION_PARTS[2] = 0 | ||
elsif BUMP_TYPE == "minor" | ||
VERSION_PARTS[1] += 1 | ||
VERSION_PARTS[2] = 0 | ||
elsif BUMP_TYPE == "patch" | ||
VERSION_PARTS[2] += 1 | ||
end | ||
NEW_VERSION = VERSION_PARTS.join(".") | ||
|
||
# Update version in main.swift for ArgumentParser | ||
%x[sed -i '' 's/#{VERSION}/#{NEW_VERSION}/g' Sources/Pods/main.swift] | ||
# Update version for Homebrew | ||
%x[sed -i '' 's/#{VERSION}/#{NEW_VERSION}/g' Formula/pods.rb] | ||
# Add bump commit | ||
%x[git commit -i Sources/Pods/main.swift Formula/pods.rb -m "Bump version #{NEW_VERSION}"] | ||
# Add new git tag | ||
%x[git tag #{NEW_VERSION}] | ||
|
||
puts BUMP_TYPE.capitalize + ": " + VERSION + " → " + NEW_VERSION |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
name: Release | ||
|
||
on: | ||
workflow_dispatch: | ||
inputs: | ||
bump-type: | ||
type: choice | ||
required: true | ||
options: | ||
- patch | ||
- minor | ||
- major | ||
|
||
permissions: | ||
contents: write | ||
discussions: write | ||
|
||
jobs: | ||
bump: | ||
runs-on: macos-11.0 | ||
steps: | ||
# Checkout with custom token for pushin to protected branch | ||
- uses: actions/checkout@v3 | ||
with: | ||
token: ${{ secrets.CUSTOM_GITHUB_TOKEN }} | ||
|
||
# Update version in all files, commit, add tag and push | ||
- run: | | ||
git config user.name "GitHub Actions" | ||
git config user.email "swiftyfinch@yandex.com" | ||
ruby .github/scripts/bump.rb ${{ github.event.inputs.bump-type }} | ||
# Build binary | ||
- uses: maxim-lobanov/setup-xcode@v1 | ||
with: { xcode-version: '13.0' } | ||
- name: Build Pods | ||
run: | | ||
swift build -c release --arch arm64 --arch x86_64 | ||
swift run pods --version | ||
path=`swift build -c release --arch arm64 --arch x86_64 --show-bin-path` | ||
mkdir -p pods/bin && mv $path/pods pods/bin | ||
zip -r pods.zip pods | ||
# Push tag and commit | ||
- run: | | ||
echo "release_tag=`git describe --tags --abbrev=0`" >> $GITHUB_ENV | ||
git push origin | ||
git push origin `git describe --tags --abbrev=0` | ||
# Create release and discussion | ||
- name: Release | ||
uses: softprops/action-gh-release@v1 | ||
with: | ||
name: 🌱 Pods ${{ env.release_tag }} | ||
generate_release_notes: true | ||
discussion_category_name: Releases | ||
fail_on_unmatched_files: true | ||
files: pods.zip | ||
tag_name: ${{ env.release_tag }} |