Skip to content

Commit

Permalink
Merge pull request #6 from dokku/simplify-usage
Browse files Browse the repository at this point in the history
refactor: remove shell entrypoint
  • Loading branch information
josegonzalez authored May 16, 2024
2 parents 0f2e7f9 + a51563b commit 8b5b540
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 38 deletions.
3 changes: 1 addition & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,5 @@ FROM alpine:3.19.1
# hadolint ignore=DL3018
RUN apk add --no-cache bash
COPY --from=builder /go/src/github.com/dokku/semver/semver /usr/local/bin/semver
COPY entrypoint /usr/local/bin/entrypoint
ENTRYPOINT ["/usr/local/bin/entrypoint"]
ENTRYPOINT ["/usr/local/bin/semver"]
LABEL org.opencontainers.image.description "A tool for generating a semver version from an existing version and a desired bump level"
3 changes: 0 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,6 @@ docker build --progress plain -t semver .

# run it with arguments
docker run --rm semver --input 0.1.2 --bump patch

# run it with environment variables
docker run --rm -e SEMVER_GENERATOR_INPUT=0.1.2 -e SEMVER_GENERATOR_BUMP=patch semver
```

## Releasing
Expand Down
9 changes: 5 additions & 4 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ inputs:
runs:
using: "docker"
image: "Dockerfile"
entrypoint: "/usr/local/bin/entrypoint"
env:
SEMVER_GENERATOR_BUMP: ${{ inputs.bump }}
SEMVER_GENERATOR_INPUT: ${{ inputs.input }}
args:
- "--bump"
- ${{ inputs.bump }}
- "--input"
- ${{ inputs.input }}
26 changes: 0 additions & 26 deletions entrypoint

This file was deleted.

21 changes: 18 additions & 3 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,24 @@ func main() {
parsed.Patch += 1
}

updatedVersion := parsed.String()
if addPrefix {
fmt.Printf("v" + parsed.String() + "\n")
} else {
fmt.Printf(parsed.String() + "\n")
updatedVersion = "v" + parsed.String()
}

fmt.Printf(updatedVersion + "\n")
githubOutput := os.Getenv("GITHUB_OUTPUT")
if githubOutput != "" {
f, err := os.OpenFile(githubOutput, os.O_APPEND|os.O_WRONLY|os.O_CREATE, 0600)
if err != nil {
slog.Error("Failed to open file", "file", githubOutput, "error", err.Error())
os.Exit(1)
}
defer f.Close()

if _, err = f.WriteString(fmt.Sprintf("VERSION=%s", updatedVersion)); err != nil {
slog.Error("Failed to write to file", "file", githubOutput, "error", err.Error())
os.Exit(1)
}
}
}

0 comments on commit 8b5b540

Please sign in to comment.