StephanHCB / go-generator-cli

command line tool to scaffold application code or other files from templates
MIT License
7 stars 5 forks source link

chore(release): add automatic version #19

Closed Avataw closed 4 months ago

Avataw commented 6 months ago

I wasn't able to perfectly test it as my forked repository does not have any releases yet.

I've added a step to the workflow that dry-runs the semantic release. This step automatically sets the version variable.

The version variable is being used by the go build command: run: go build -ldflags="-X 'main.version=${{ steps.version.outputs.VERSION }}'"

This injects the variable into the variable declared in the main.go.

I've thought about having a separate file version.go or something like that, but I've opted against it. It might make sense in the future if you want to enable the customary --version flag.