Commit bcbb0c1
Changed files (6)
.github/workflows/release.yml
@@ -0,0 +1,29 @@
+name: release
+
+on:
+ push:
+ tags:
+ - "v*"
+
+permissions:
+ contents: write
+
+jobs:
+ goreleaser:
+ runs-on: ubuntu-latest
+ steps:
+ - uses: actions/checkout@v4
+ with:
+ fetch-depth: 0
+
+ - uses: actions/setup-go@v5
+ with:
+ go-version-file: go.mod
+
+ - uses: goreleaser/goreleaser-action@v6
+ with:
+ distribution: goreleaser
+ version: "~> v2"
+ args: release --clean
+ env:
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
internal/component.go
@@ -43,7 +43,7 @@ func documentFromXML(c *xmlCircuit) *Circuit {
}
return &Circuit{
- Version: "0.1",
+ Version: Version,
CircuitDiagramVersion: c.Version,
Components: components,
Connections: collectConnections(c.Components, components),
internal/version.go
@@ -0,0 +1,5 @@
+package internal
+
+// Release builds overwrite this via:
+// -ldflags "-X cddx2yaml/internal.Version=<tag>"
+var Version = "dev"
.gitignore
@@ -0,0 +1,6 @@
+dist/
+/cddx2yaml
+/cddx2yaml.exe
+/main
+*.exe
+circuit.yaml
\ No newline at end of file
.goreleaser.yaml
@@ -0,0 +1,39 @@
+version: 2
+
+project_name: cddx2yaml
+
+before:
+ hooks:
+ - go mod tidy
+
+builds:
+ - env:
+ - CGO_ENABLED=0
+ goos:
+ - linux
+ - darwin
+ - windows
+ goarch:
+ - amd64
+ - arm64
+ ldflags:
+ - -s -w -X cddx2yaml/internal.Version={{.Version}}
+
+archives:
+ - formats: [tar.gz]
+ name_template: >-
+ {{ .ProjectName }}_{{ .Version }}_{{ .Os }}_
+ {{- if eq .Arch "amd64" }}x86_64
+ {{- else if eq .Arch "arm64" }}aarch64
+ {{- else }}{{ .Arch }}{{ end }}
+ format_overrides:
+ - goos: windows
+ formats: [zip]
+ files:
+ - README.md
+
+checksum:
+ name_template: checksums.txt
+
+changelog:
+ sort: asc
main.go
@@ -10,6 +10,11 @@ import (
)
func main() {
+ if len(os.Args) > 1 && (os.Args[1] == "-v" || os.Args[1] == "--version") {
+ fmt.Println(internal.Version)
+ return
+ }
+
path, outputPath := "circuit.cddx", "circuit.yaml"
if len(os.Args) > 1 {