Skip to content

Commit

Permalink
feat: small improvements label based versioning (#187)
Browse files Browse the repository at this point in the history
* feat: small improvements label based versioning

* feat: update
  • Loading branch information
ryan-timothy-albert authored Nov 12, 2024
1 parent 8173f33 commit 0cae241
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 4 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/workflow-executor.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ jobs:
short_circuit_label_trigger: ${{ steps.check-label.outputs.short_circuit_label_trigger }}
steps:
- name: Check Pull Request Label
if: ${{ github.event_name == 'pull_request' && github.event.action == 'labeled' }}
if: ${{ github.event_name == 'pull_request' && (github.event.action == 'labeled' || github.event.action == 'unlabeled') }}
id: check-label
continue-on-error: true
run: |
Expand All @@ -178,7 +178,7 @@ jobs:
# Check if the label is a valid version bump and ensure the current PR isn't already on that version bump
# If either are true we short circuit the rest of the action
if [[ "$label" != "patch" && "$label" != "minor" && "$label" != "major" && "$label" != "graduate" ]] || grep -Fq "Version Bump Type: [$label]" "$tmpfile"; then
if [[ "$label" != "patch" && "$label" != "minor" && "$label" != "major" && "$label" != "graduate" ]] || { [[ "${{ github.event.action }}" == "labeled" ]] && grep -Fq "Version Bump Type: [$label]" "$tmpfile"; }; then
echo "No version bump label found in PR body. Short-circuiting."
echo "short_circuit_label_trigger=true" >> "$GITHUB_OUTPUT"
exit 0
Expand Down
3 changes: 2 additions & 1 deletion internal/git/git.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import (
"github.com/speakeasy-api/sdk-generation-action/internal/logging"
"github.com/speakeasy-api/sdk-generation-action/internal/versionbumps"
"github.com/speakeasy-api/sdk-generation-action/pkg/releases"
"github.com/speakeasy-api/versioning-reports/versioning"

"github.com/google/go-github/v63/github"
"golang.org/x/oauth2"
Expand Down Expand Up @@ -540,7 +541,7 @@ Based on:
body += stripCodes(info.VersioningInfo.VersionReport.GetMarkdownSection())

// We keep track of explicit bump types and whether that bump type is manual or automated in the PR body
if labelBumpType != nil {
if labelBumpType != nil && *labelBumpType != versioning.BumpCustom && *labelBumpType != versioning.BumpNone {
// be very careful if changing this it critically aligns with a regex in parseBumpFromPRBody
versionBumpMsg := "Version Bump Type: " + fmt.Sprintf("[%s]", string(*labelBumpType)) + " - "
if info.VersioningInfo.ManualBump {
Expand Down
2 changes: 1 addition & 1 deletion internal/git/labels.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ func PRVersionMetadata(m *versioning.MergedVersionReport, labelTypes map[string]
singleBumpType := ""
singleNewVersion := ""
for _, report := range m.Reports {
if len(report.BumpType) > 0 && report.BumpType != versioning.BumpNone && report.BumpType != versioning.BumpCustom {
if len(report.BumpType) > 0 && report.BumpType != versioning.BumpNone {
if len(singleBumpType) > 0 {
skipBumpType = true
}
Expand Down
1 change: 1 addition & 0 deletions internal/versionbumps/versionBumps.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ var bumpTypeLabels = map[versioning.BumpType]string{
versioning.BumpPatch: "Patch version bump",
versioning.BumpGraduate: "Graduate prerelease to stable",
versioning.BumpPrerelease: "Bump by a prerelease version",
versioning.BumpCustom: "A custom version was applied",
}

type VersioningInfo struct {
Expand Down

0 comments on commit 0cae241

Please sign in to comment.