Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
88 changes: 88 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
---
name: Release
permissions:
contents: read
on:
push:
tags:
- "v[0-9]+.[0-9]+.[0-9]+"

jobs:
test:
name: test
runs-on: ubuntu-latest
steps:
- name: checkout code
uses: actions/checkout@93cb6efe18208431cddfb8368fd83d5badbf9bfd # v5.0.1
with:
persist-credentials: false
- name: setup go
uses: actions/setup-go@4a3601121dd01d1626a1e23e37211e3254c1c06c # v6.4.0
with:
go-version: "1.25"
cache: false
- name: install stringer
run: go install golang.org/x/tools/cmd/stringer@v0.44.0
- name: run go generate
run: go generate ./...
- name: check if new files have been generated
run: git diff --exit-code
- name: run tests
run: go test ./... -count=1

build:
name: build ${{ matrix.goos }}/${{ matrix.goarch }}
needs: test
runs-on: ubuntu-latest
strategy:
matrix:
include:
- goos: linux
goarch: amd64
- goos: linux
goarch: arm64
- goos: darwin
goarch: amd64
- goos: darwin
goarch: arm64
steps:
- name: checkout code
uses: actions/checkout@93cb6efe18208431cddfb8368fd83d5badbf9bfd # v5.0.1
with:
persist-credentials: false
- name: setup go
uses: actions/setup-go@4a3601121dd01d1626a1e23e37211e3254c1c06c # v6.4.0
with:
go-version: "1.25"
cache: false
- name: build
env:
GOOS: ${{ matrix.goos }}
GOARCH: ${{ matrix.goarch }}
run: |
go build \
-ldflags="-w -X main.version=${GITHUB_REF_NAME}" \
-o noclickops-${{ matrix.goos }}-${{ matrix.goarch }} \
.
- name: upload artifact
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: noclickops-${{ matrix.goos }}-${{ matrix.goarch }}
path: noclickops-${{ matrix.goos }}-${{ matrix.goarch }}

release:
name: release
needs: build
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: download artifacts
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
merge-multiple: true
- name: create release
uses: softprops/action-gh-release@b4309332981a82ec1c5618f44dd2e27cc8bfbfda # v3.0.0
with:
files: noclickops-*
generate_release_notes: true
2 changes: 2 additions & 0 deletions .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ jobs:
steps:
- name: checkout code
uses: actions/checkout@93cb6efe18208431cddfb8368fd83d5badbf9bfd # v5.0.1
with:
persist-credentials: false
- name: setup go
uses: actions/setup-go@4a3601121dd01d1626a1e23e37211e3254c1c06c # v6.4.0
with:
Expand Down
9 changes: 9 additions & 0 deletions config.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"errors"
"fmt"
"log"
"os"
"slices"
"strings"

Expand Down Expand Up @@ -173,8 +174,16 @@ func loadConfig() NoclickopsConfig {
pflag.BoolP(configValues[DeleteDownloadedStateFiles], "d", false, "If specified, any downloaded statefiles will be deleted at the end")
pflag.BoolP(configValues[ForceDownload], "f", false, "If specified, it will download all the files from the bucket even they overwrite existing ones")
pflag.BoolP(configValues[GenerateHTMLReport], "g", false, "If specified, it will generate an html report in the current directory")

// this is different because we use it and exit straight away
versionFlag := pflag.BoolP("version", "V", false, "Print version and exit")
pflag.Parse()

if *versionFlag {
fmt.Printf("noclickops %s\n", version)
os.Exit(0)
}

// use this to pass control to viper
// This means that any references to `statefile` will be resolved in the
// right order (i.e. default, config, env, commandline)
Expand Down
2 changes: 2 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ import (
"github.com/noclickops/common"
)

var version = "dev"

func main() {
config := loadConfig()

Expand Down