Skip to content
This repository was archived by the owner on Aug 9, 2023. It is now read-only.

Commit 27fb35b

Browse files
committed
Migrated away from unsupported actions
1 parent 5d8f0b5 commit 27fb35b

1 file changed

Lines changed: 57 additions & 35 deletions

File tree

  • java/github-actions-builder/src/main/java/com/octopus/githubactions/shared/builders

java/github-actions-builder/src/main/java/com/octopus/githubactions/shared/builders/GitBuilder.java

Lines changed: 57 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,13 @@
88
import lombok.NonNull;
99
import org.apache.commons.lang3.StringUtils;
1010

11-
/** Contains a number of common steps shared between builders. */
11+
/**
12+
* Contains a number of common steps shared between builders.
13+
*/
1214
public class GitBuilder {
13-
/** Builds the common top level comments for the workflow. */
15+
/**
16+
* Builds the common top level comments for the workflow.
17+
*/
1418
public String getInitialComments() {
1519
return "# The following workflow provides an opinionated template you can customize for your own needs.\n"
1620
+ "#\n"
@@ -26,15 +30,19 @@ public String getInitialComments() {
2630
+ "# Get a trial Octopus instance from https://octopus.com/start\n";
2731
}
2832

29-
/** Build the checkout step. */
33+
/**
34+
* Build the checkout step.
35+
*/
3036
public Step checkOutStep() {
3137
return UsesWith.builder()
3238
.uses("actions/checkout@v3")
3339
.with(new ImmutableMap.Builder<String, String>().put("fetch-depth", "0").build())
3440
.build();
3541
}
3642

37-
/** Build the GitVersion installation step. */
43+
/**
44+
* Build the GitVersion installation step.
45+
*/
3846
public Step gitVersionInstallStep() {
3947
return UsesWith.builder()
4048
.name("Install GitVersion")
@@ -43,7 +51,9 @@ public Step gitVersionInstallStep() {
4351
.build();
4452
}
4553

46-
/** Build the step to calculate the versions from git. */
54+
/**
55+
* Build the step to calculate the versions from git.
56+
*/
4757
public Step getVersionCalculate() {
4858
return UsesWith.builder()
4959
.name("Determine Version")
@@ -53,7 +63,9 @@ public Step getVersionCalculate() {
5363
.build();
5464
}
5565

56-
/** Build the Octopus CLI installation step. */
66+
/**
67+
* Build the Octopus CLI installation step.
68+
*/
5769
public Step installOctopusCli() {
5870
return UsesWith.builder()
5971
.name("Install Octopus Deploy CLI")
@@ -62,7 +74,9 @@ public Step installOctopusCli() {
6274
.build();
6375
}
6476

65-
/** Build the test processing step. */
77+
/**
78+
* Build the test processing step.
79+
*/
6680
public Step buildJunitReport(@NonNull final String name, @NonNull final String path) {
6781
return UsesWith.builder()
6882
.name("Report")
@@ -89,22 +103,20 @@ public Step createGitHubRelease(@NonNull final RepoClient accessor) {
89103
return UsesWith.builder()
90104
.name("Create Release")
91105
.id("create_release")
92-
.uses("actions/create-release@v1")
93-
.env(
94-
new ImmutableMap.Builder<String, String>()
95-
.put("GITHUB_TOKEN", "${{ secrets.GITHUB_TOKEN }}")
96-
.build())
106+
.uses("softprops/action-gh-release@v1")
97107
.with(
98108
new ImmutableMap.Builder<String, String>()
99109
.put("tag_name", "${{ steps.determine_version.outputs.semVer }}+run${{ github.run_number }}-attempt${{ github.run_attempt }}")
100110
.put("release_name", "Release ${{ steps.determine_version.outputs.semVer }} Run ${{ github.run_number }} Attempt ${{ github.run_attempt }}")
101111
.put("draft", "${{ github.ref == 'refs/heads/" + accessor.getDefaultBranches().get(0) + "' && 'false' || 'true' }}")
102-
.put("prerelease", "${{ github.ref == 'refs/heads/" + accessor.getDefaultBranches().get(0) + "' && 'false' || 'true' }}")
112+
.put("name", "${{ github.ref == 'refs/heads/" + accessor.getDefaultBranches().get(0) + "' && 'false' || 'true' }}")
103113
.build())
104114
.build();
105115
}
106116

107-
/** Tag the repo with the release. */
117+
/**
118+
* Tag the repo with the release.
119+
*/
108120
public Step tagRepo() {
109121
return UsesWith.builder()
110122
.name("Tag Release")
@@ -117,26 +129,24 @@ public Step tagRepo() {
117129
.build();
118130
}
119131

120-
/** Build the step to upload file to the github release. */
132+
/**
133+
* Build the step to upload file to the github release.
134+
*/
121135
public Step uploadToGitHubRelease(@NonNull final String path, @NonNull final String name) {
122136
return UsesWith.builder()
123137
.name("Upload Release Asset")
124-
.uses("actions/upload-release-asset@v1")
125-
.env(
126-
new ImmutableMap.Builder<String, String>()
127-
.put("GITHUB_TOKEN", "${{ secrets.GITHUB_TOKEN }}")
128-
.build())
138+
.uses("softprops/action-gh-release@v1")
129139
.with(
130140
new ImmutableMap.Builder<String, String>()
131-
.put("upload_url", "${{ steps.create_release.outputs.upload_url }}")
132-
.put("asset_path", path)
133-
.put("asset_name", name)
134-
.put("asset_content_type", "application/octet-stream")
141+
.put("tag_name", "${{ steps.determine_version.outputs.semVer }}+run${{ github.run_number }}-attempt${{ github.run_attempt }}")
142+
.put("files", path)
135143
.build())
136144
.build();
137145
}
138146

139-
/** Build the step to push files to Octopus. */
147+
/**
148+
* Build the step to push files to Octopus.
149+
*/
140150
public Step pushToOctopus(@NonNull final String packages) {
141151
return UsesWith.builder()
142152
.name("Push packages to Octopus Deploy")
@@ -154,7 +164,9 @@ public Step pushToOctopus(@NonNull final String packages) {
154164
.build();
155165
}
156166

157-
/** Build the step to push Octopus build information. */
167+
/**
168+
* Build the step to push Octopus build information.
169+
*/
158170
public Step uploadOctopusBuildInfo(@NonNull final RepoClient accessor) {
159171
return UsesWith.builder()
160172
.name("Generate Octopus Deploy build information")
@@ -173,16 +185,18 @@ public Step uploadOctopusBuildInfo(@NonNull final RepoClient accessor) {
173185
.build();
174186
}
175187

176-
/** Build the step to create an Octopus release. */
188+
/**
189+
* Build the step to create an Octopus release.
190+
*/
177191
public Step createOctopusRelease(@NonNull final RepoClient accessor, @NonNull final String packages) {
178192
return UsesWith.builder()
179193
.name("Create Octopus Release")
180194
.uses("OctopusDeploy/create-release-action@v3")
181195
.env(new ImmutableMap.Builder<String, String>()
182-
.put("OCTOPUS_API_KEY", "${{ secrets.OCTOPUS_API_TOKEN }}")
183-
.put("OCTOPUS_URL", "${{ secrets.OCTOPUS_SERVER_URL }}")
184-
.put("OCTOPUS_SPACE", "${{ secrets.OCTOPUS_SPACE }}")
185-
.build())
196+
.put("OCTOPUS_API_KEY", "${{ secrets.OCTOPUS_API_TOKEN }}")
197+
.put("OCTOPUS_URL", "${{ secrets.OCTOPUS_SERVER_URL }}")
198+
.put("OCTOPUS_SPACE", "${{ secrets.OCTOPUS_SPACE }}")
199+
.build())
186200
.with(
187201
new ImmutableMap.Builder<String, String>()
188202
.put("project", accessor.getRepoName().getOrElse("application"))
@@ -195,7 +209,9 @@ public Step collectDependencies() {
195209
return collectDependencies(null);
196210
}
197211

198-
/** Build the dependency collection step. */
212+
/**
213+
* Build the dependency collection step.
214+
*/
199215
public Step collectDependencies(final String workingDirectory) {
200216
final String directory = StringUtils.isBlank(workingDirectory)
201217
? "" : workingDirectory + "/";
@@ -214,7 +230,9 @@ public Step collectDependencyUpdates() {
214230
return collectDependencyUpdates(null);
215231
}
216232

217-
/** Build the dependency updates collection step. */
233+
/**
234+
* Build the dependency updates collection step.
235+
*/
218236
public Step collectDependencyUpdates(final String workingDirectory) {
219237
final String directory = StringUtils.isBlank(workingDirectory)
220238
? "" : workingDirectory + "/";
@@ -229,7 +247,9 @@ public Step collectDependencyUpdates(final String workingDirectory) {
229247
.build();
230248
}
231249

232-
/** Build the java installation step. */
250+
/**
251+
* Build the java installation step.
252+
*/
233253
public Step installJava() {
234254
return UsesWith.builder()
235255
.name("Set up JDK 1.17")
@@ -242,7 +262,9 @@ public Step installJava() {
242262
.build();
243263
}
244264

245-
/** Build the permissions object. */
265+
/**
266+
* Build the permissions object.
267+
*/
246268
public Permissions buildPermissions() {
247269
return Permissions.builder()
248270
.contents("write")

0 commit comments

Comments
 (0)