Skip to content

Instantly share code, notes, and snippets.

@peteruhnak
Last active March 28, 2021 17:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save peteruhnak/bfb8bac6b6de89e67ef0eb561eba51cb to your computer and use it in GitHub Desktop.
Save peteruhnak/bfb8bac6b6de89e67ef0eb561eba51cb to your computer and use it in GitHub Desktop.
Iceberg git release with tags
"
Release 'master' branch of <repoName>:
1. merge it into release_base repository
2. adjust baseline if necessary
3. commit & push to origin/release_base
4. multi-tag with SEMVER (v1.2.3, v1.2.x, v1.x)
5. delete & push remote tags
"
"[MODIFY] repo to process"
repoName := 'uml-shapes'.
"[MODIFY] new release version"
newTag := #(2 0 3).
"finding repository"
repo := IceRepository registry detect: [ :each | each name = repoName ].
repoModel := IceTipRepositoryModel on: repo.
"grab remote branch"
remoteBranch := repo allBranches detect: [ :b | b name = 'origin/release_base' ].
remoteBranchModel := IceTipBranchModel repositoryModel: repoModel on: remoteBranch.
"if not available locally, yet, checkout remote"
repo allBranches
detect: [ :b | b name = 'release_base' ]
ifNone: [ |remoteBranch remoteBranchModel|
"perform checkout via GUI"
remoteBranchModel previewCheckout.
].
"grab local release_base"
releaseBranch := repo allBranches detect: [ :b | b name = 'release_base' ].
releaseBranchModel := IceTipBranchModel repositoryModel: repoModel on: releaseBranch.
"perform checkout via GUI"
releaseBranchModel previewCheckout.
"pull to ensure it is up to date"
releaseBranch pullFrom: remoteBranch remote.
"get master branch"
masterBranch := repo allBranches detect: [ :b | b name = 'master' ].
masterBranchModel := IceTipBranchModel repositoryModel: repoModel on: masterBranch.
"merge master branch into the currently checked-out (which is the release branch)"
masterBranchModel previewMerge: IceTipMergeType direct.
"
[MODIFY] MAKE NECESSARY CHANGES BY HAND IN THE BASELINE/CODE
"
"commit via GUI"
(IceTipCommitBrowser onRepository: repo) openWithSpec.
"push the changes to GitHub"
releaseBranch pushTo: remoteBranch remote.
"preparing tags"
commitToTag := releaseBranch commit.
tags := repo tags.
"conversion util"
verToTag := [ :t | 'v', (t joinUsing: '.') ].
"create patch tag v1.2.3"
patchTag := verToTag value: newTag.
tags detect: [ :t | t name = patchTag ] ifFound: [ :t | self error: 'Patch tag ', patchTag, ' already exists' ].
commitToTag createTag: patchTag.
"create minor tag v1.2.x"
minorTag := verToTag value: (newTag first: 2), { 'x' }.
tags detect: [ :t | t name = minorTag ] ifFound: [ :t | repo removeTag: t ].
commitToTag createTag: minorTag.
"create major tag v1.x"
majorTag := verToTag value: { newTag first. 'x' }.
tags detect: [ :t | t name = majorTag ] ifFound: [ :t | repo removeTag: t ].
commitToTag createTag: majorTag.
"[EXTERNAL] execute in command line to clean & push tags"
String << [ :s |
s << 'pushd "' << repo location fullName << '"'.
s lf.
s << ('git push --delete origin {1} {2}' format: { minorTag. majorTag }).
s lf.
s << 'git push --tags'
]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment