Skip to content

Commit

Permalink
Reduced manual steps for releasing
Browse files Browse the repository at this point in the history
  • Loading branch information
JanBliznicenko committed Oct 28, 2024
1 parent 4ab3ddf commit 339ab22
Show file tree
Hide file tree
Showing 2 changed files with 142 additions and 43 deletions.
6 changes: 4 additions & 2 deletions repository/BaselineOfOpenPonk/BaselineOfOpenPonk.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,12 @@ BaselineOfOpenPonk >> baseline: spec [
package: 'OpenPonk-Morphic';
package: 'OpenPonk-Spec' with: [
spec requires:
#( 'NewTools' 'Magritte' 'SynchronizedLinks' 'OpenPonk-Morphic' ) ].
#( 'NewTools' 'Magritte' 'SynchronizedLinks' 'OpenPonk-Morphic' ) ];
package: 'OpenPonk-Releaser'.
spec
group: 'default'
with: #( 'OpenPonk-Core' 'OpenPonk-Morphic' 'OpenPonk-Spec' ) ]
with: #( 'OpenPonk-Core' 'OpenPonk-Morphic' 'OpenPonk-Spec' );
group: 'dev' with: #( 'default' 'OpenPonk-Releaser' ) ]
]

{ #category : 'baselines' }
Expand Down
179 changes: 138 additions & 41 deletions repository/OpenPonk-Releaser/OPReleaser.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -11,36 +11,52 @@ Class {
'remoteBranch',
'releaseBranch',
'minorTag',
'majorTag'
'majorTag',
'job'
],
#category : 'OpenPonk-Releaser',
#package : 'OpenPonk-Releaser'
}

{ #category : 'as yet unclassified' }
OPReleaser class >> defaultBranch [

^ 'master'
]

{ #category : 'as yet unclassified' }
OPReleaser class >> releaseRepositories: aCollectionOfString asVersion: anArrayOfNumbers [

[
aCollectionOfString do: [ :each |
self releaseRepository: each asVersion: anArrayOfNumbers ]
self new
repositoryName: each;
version: anArrayOfNumbers;
createGitCommands ] ]
forkAt: Processor userBackgroundPriority
named: 'OPReleaser'
]

{ #category : 'as yet unclassified' }
OPReleaser class >> releaseRepository: aName asVersion: anArrayOfNumbers [

^ self new
repositoryName: aName;
versionArray: anArrayOfNumbers;
inspectGitCommands
self
releaseRepository: aName
branch: self defaultBranch
asVersion: anArrayOfNumbers
]

{ #category : 'as yet unclassified' }
OPReleaser class >> releaseRepository: aName branch: aString asVersion: anArrayOfNumbers [

^ self new
repositoryName: aName;
branch: aString;
versionArray: anArrayOfNumbers;
inspectGitCommands
[
self new
repositoryName: aName;
branch: aString;
version: anArrayOfNumbers;
createGitCommands ]
forkAt: Processor userBackgroundPriority
named: 'OPReleaser'
]

{ #category : 'instance creation' }
Expand All @@ -52,27 +68,33 @@ OPReleaser >> branch: aBranchName [
{ #category : 'actions' }
OPReleaser >> checkoutLocalReleaseBranch [

| releaseBranchModel |
| releaseBranchModel checkoutBrowser |
"grab local release_base"
job title: 'Looking for release_base'.
releaseBranch := repo allBranches detect: [ :b |
b name = 'release_base' ].
releaseBranchModel := IceTipBranchModel
repositoryModel: repoModel
on: releaseBranch.

"perform checkout via GUI"
releaseBranchModel previewCheckout.
checkoutBrowser := (IceTipCheckoutPreviewBrowser onBranch: releaseBranchModel).
checkoutBrowser diffPanel model diff isEmpty ifTrue: [ ^ self ].
checkoutBrowser open

"------------- HANDLE OPEN WINDOWS IF ANY ----------------"
self confirmToContinue:
'If any window opened, handle checkout release_base, then proceed'
job title: 'Waiting: Confirm checkout release_base'.
self waitForWindows: [
IceTipCheckoutPreviewBrowser allInstances select: [ :each |
each hasWindow and: [ each window isOpen ] ] ]
]

{ #category : 'actions' }
OPReleaser >> checkoutRemoteReleaseBranch [
"grab remote branch"

| remoteBranchModel |
| remoteBranchModel checkoutBrowser |
job title: 'Looking for origin/release_base'.
remoteBranch := repo allBranches detect: [ :b |
b name = 'origin/release_base' ].
remoteBranchModel := IceTipBranchModel
Expand All @@ -82,32 +104,42 @@ OPReleaser >> checkoutRemoteReleaseBranch [
"if not available locally, yet, checkout remote"
repo allBranches
detect: [ :b | b name = 'release_base' ]
ifNone: [ "perform checkout via GUI"
remoteBranchModel previewCheckout ].
ifFound: [ ^ self ].

checkoutBrowser := IceTipCheckoutPreviewBrowser onBranch:
remoteBranchModel.
checkoutBrowser diffPanel model diff isEmpty ifTrue: [ ^ self ].
checkoutBrowser open.

"------------- HANDLE OPEN WINDOWS IF ANY ----------------"
self confirmToContinue:
'If any window opened, handle checkout release_base, then proceed'
job title: 'Waiting: Confirm checkout release_base'.
self waitForWindows: [
IceTipCheckoutPreviewBrowser allInstances select: [ :each |
each hasWindow and: [ each window isOpen ] ] ]
]

{ #category : 'actions' }
OPReleaser >> commit [

| commitBrowser |

"------------- HANDLE OPEN WINDOWS IF ANY ----------------"
"------- MAKE NECESSARY CHANGES BY HAND IN THE BASELINE/CODE -------"

job title:
'Waiting: Change baseline if neccessary, then confirm dialog'.
self confirmToContinue:
'Handle open merge window, make neccessary changes in the baseline, then proceed'.
'Change baseline if neccessary, then click OK'.

"commit via GUI"

job title: 'Preparing commit'.
commitBrowser := IceTipCommitBrowser onRepository: repo.
commitBrowser diffPanel model isEmpty ifTrue: [ ^ self ].
commitBrowser commentPanel commentText text: 'Updated baseline'.
commitBrowser open.

"------------- HANDLE OPEN WINDOWS IF ANY ----------------"
self confirmToContinue: 'Handle commit window, then proceed'
job title: 'Waiting: Confirm commit'.
self waitForWindows: [
IceTipCommitBrowser allInstances select: [ :each |
each hasWindow and: [ each window isOpen ] ] ]
]

{ #category : 'utilities' }
Expand All @@ -117,6 +149,35 @@ OPReleaser >> confirmToContinue: aText [
self notify: 'Release script cancelled' ]
]

{ #category : 'actions' }
OPReleaser >> createGitCommands [

[
job := [ self createGitCommandsInJob ] asJob.
job run ] asJob
title: 'Creating release of ' , repositoryName asString;
run
]

{ #category : 'actions' }
OPReleaser >> createGitCommandsInJob [

job title: 'Creating release'.
gitCommands ifNil: [ self createRelease ].
job title: 'Copying git commands to clipboard'.
Clipboard
clipboardText: gitCommands
informing: 'Git commands copied to clipboard - run them in terminal'.
gitCommands inspect.
job title: 'Waiting: Run git commands and close the inspector'.
self waitForWindows: [
StInspectorPresenter allInstances select: [ :each |
each hasWindow and: [
each window isOpen and: [
each model inspectedObject isString and: [
each model inspectedObject beginsWith: 'pushd "' ] ] ] ] ]
]

{ #category : 'actions' }
OPReleaser >> createRelease [

Expand All @@ -135,6 +196,7 @@ OPReleaser >> createTags [
"preparing tags"

| commitToTag tags verToTag patchTag |
job title: 'Creating tags'.
commitToTag := releaseBranch commit.

tags := repo tags.
Expand Down Expand Up @@ -170,6 +232,7 @@ OPReleaser >> createTags [
{ #category : 'actions' }
OPReleaser >> getGitCommands [

job title: 'Generating tag git push commands'.
^ gitCommands := String streamContents: [ :s |
s << 'pushd "' << repo location fullName << '"'.
s lf.
Expand All @@ -184,6 +247,7 @@ OPReleaser >> getGitCommands [
{ #category : 'actions' }
OPReleaser >> getRepo [

job title: 'Finding local repository'.
repo := IceRepository registry detect: [ :each |
each name = repositoryName ].
repoModel := IceTipRepositoryModel on: repo
Expand All @@ -193,39 +257,46 @@ OPReleaser >> getRepo [
OPReleaser >> initialize [

super initialize.
nightlyBranchName := 'master'
]

{ #category : 'actions' }
OPReleaser >> inspectGitCommands [

^ (gitCommands ifNil: [ self createRelease ])
inspect;
yourself
nightlyBranchName := self class defaultBranch.
job := Job new
]

{ #category : 'actions' }
OPReleaser >> pullReleaseBranchAndMerge [

| masterBranch masterBranchModel |

| masterBranch masterBranchModel mergeBrowser |
"pull to ensure it is up to date"
job title: 'Pulling release_base'.
releaseBranch pullFrom: remoteBranch remote.

"get master branch"
masterBranch := repo allBranches detect: [ :b | b name = nightlyBranchName ].
job title: 'Looking for ' , nightlyBranchName.
masterBranch := repo allBranches detect: [ :b |
b name = nightlyBranchName ].
masterBranchModel := IceTipBranchModel
repositoryModel: repoModel
on: masterBranch.

"merge master branch into the currently checked-out (which is the release branch)"
masterBranchModel previewMerge: IceTipMergeType direct
job title:
'Preparing merge of ' , nightlyBranchName , ' into release_base'.
mergeBrowser := IceTipMergePreviewBrowser onBranch: masterBranchModel.
mergeBrowser mergeType: IceTipMergeType direct.
mergeBrowser diffPanel model diff isEmpty ifTrue: [ ^ self ].
mergeBrowser open.

job title: 'Waiting: Confirm merge of ' , nightlyBranchName
, ' into release_base'.
self waitForWindows: [
IceTipMergePreviewBrowser allInstances select: [ :each |
each hasWindow and: [ each window isOpen ] ] ]
]

{ #category : 'actions' }
OPReleaser >> push [
"push the changes to GitHub"

job title: 'Pushing'.
releaseBranch pushTo: remoteBranch remote
]

Expand All @@ -236,7 +307,33 @@ OPReleaser >> repositoryName: aString [
]

{ #category : 'versions' }
OPReleaser >> versionArray: aCollection [
OPReleaser >> version: aCollection [

aCollection isString ifTrue: [
^ self versionArrayFromString: aCollection ].
self versionArrayFromCollection: aCollection
]

{ #category : 'versions' }
OPReleaser >> versionArrayFromCollection: aCollection [

self
assert: aCollection size = 3
description: [ aCollection , ' should be of size 3' ].
versionArray := aCollection collect: [ :each | each asInteger ].
self assert: (versionArray allSatisfy: [ :each |
each isInteger and: [ each positive ] ])
]

{ #category : 'versions' }
OPReleaser >> versionArrayFromString: aString [

self versionArrayFromCollection: (aString splitOn: $.)
]

{ #category : 'as yet unclassified' }
OPReleaser >> waitForWindows: aBlock [

versionArray := aCollection
250 milliseconds wait.
[ aBlock value isNotEmpty ] whileTrue: [ 250 milliseconds wait ]
]

0 comments on commit 339ab22

Please sign in to comment.