diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml
index e95e6a3..33304cf 100644
--- a/.github/workflows/release.yaml
+++ b/.github/workflows/release.yaml
@@ -13,6 +13,10 @@ jobs:
release:
name: Release
+ permissions:
+ id-token: write
+ contents: write
+
runs-on: ubuntu-latest
steps:
@@ -25,9 +29,9 @@ jobs:
run: git fetch --force --tags
- name: Setup Go
- uses: actions/setup-go@v4
+ uses: actions/setup-go@v5
with:
- go-version: 1.21.1 # datasource=github-releases depName=golang/go
+ go-version: 1.21.3 # datasource=github-releases depName=golang/go
- name: Goreleaser
uses: goreleaser/goreleaser-action@v5
diff --git a/.github/workflows/snapshot.yaml b/.github/workflows/snapshot.yaml
index b4dfe85..3e6cb41 100644
--- a/.github/workflows/snapshot.yaml
+++ b/.github/workflows/snapshot.yaml
@@ -32,6 +32,9 @@ jobs:
with:
fetch-depth: 0
+ - name: Fetch Git tags
+ run: git fetch --force --tags
+
- name: Fake terraform
run: |
echo '#!/bin/bash' | sudo tee /usr/local/bin/terraform
@@ -41,10 +44,16 @@ jobs:
- name: Setup Go
uses: actions/setup-go@v4
with:
- go-version: 1.21.1 # datasource=github-releases depName=golang/go
+ go-version: 1.21.3 # datasource=github-releases depName=golang/go
- - name: Build binary
- run: make download build
+ - name: Goreleaser
+ uses: goreleaser/goreleaser-action@v5
+ with:
+ distribution: goreleaser
+ version: 1.21.2 # datasource=github-releases depName=goreleaser/goreleaser
+ args: build --clean --snapshot --single-target --output tf
+ env:
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Test binary
run: |
diff --git a/.gitignore b/.gitignore
index 779cfb3..c571490 100644
--- a/.gitignore
+++ b/.gitignore
@@ -6,6 +6,8 @@
*.log
*.tfstate
demo-*.txt
+dist/
+tmp/
/tf
.terraform
.vscode
diff --git a/Makefile b/Makefile
index 4bbe820..1816f74 100644
--- a/Makefile
+++ b/Makefile
@@ -6,16 +6,20 @@ ifneq (,$(wildcard .env))
endif
AWK = awk
-DOCKER = docker
-ECHO = echo
GO = go
GORELEASER = goreleaser
+HEAD = head
INSTALL = install
-MAKE = make
PRINTF = printf
RM = rm
SORT = sort
+ifeq ($(OS),Darwin)
+SORT = gsort
+else
+SORT = sort
+endif
+
ifeq ($(GOOS),windows)
EXE = .exe
else ifeq ($(shell $(GO) env GOOS),windows)
@@ -40,13 +44,6 @@ BINDIR = /usr/local/bin
endif
endif
-VERSION = $(shell ( git describe --tags --exact-match 2>/dev/null || ( git describe --tags 2>/dev/null || echo "0.0.0-0-g$$(git rev-parse --short=8 HEAD)" ) | sed 's/-[0-9][0-9]*-g/-SNAPSHOT-/') | sed 's/^v//' )
-REVISION = $(shell git rev-parse HEAD)
-BUILDDATE = $(shell TZ=GMT date '+%Y-%m-%dT%R:%SZ')
-
-CGO_ENABLED = 0
-export CGO_ENABLED
-
.PHONY: help
help:
@echo Targets:
@@ -55,12 +52,7 @@ help:
.PHONY: build
build: ## Build app binary for single target
$(call print-target)
- $(GO) build -trimpath -ldflags="-s -w -X main.version=$(VERSION)"
-
-.PHONY: goreleaser
-goreleaser: ## Build app binary for all targets
- $(call print-target)
- $(GORELEASER) release --auto-snapshot --clean --skip-publish
+ $(GORELEASER) build --clean --snapshot --single-target --output $(BIN)
$(BIN):
@$(MAKE) build
@@ -97,59 +89,6 @@ clean: ## Clean working directory
$(RM) -f $(BIN)
$(RM) -rf dist
-.PHONY: version
-version: ## Show version
- @$(ECHO) "$(VERSION)"
-
-.PHONY: revision
-revision: ## Show revision
- @$(ECHO) "$(REVISION)"
-
-.PHONY: builddate
-builddate: ## Show build date
- @$(ECHO) "$(BUILDDATE)"
-
-DOCKERFILE = Dockerfile
-IMAGE_NAME = $(BIN)
-LOCAL_REPO = localhost:5000/$(IMAGE_NAME)
-DOCKER_REPO = localhost:5000/$(IMAGE_NAME)
-
-ifeq ($(PROCESSOR_ARCHITECTURE),ARM64)
-PLATFORM = linux/arm64
-else ifeq ($(shell uname -m),arm64)
-PLATFORM = linux/arm64
-else ifeq ($(shell uname -m),aarch64)
-PLATFORM = linux/arm64
-else ifeq ($(findstring ARM64, $(shell uname -s)),ARM64)
-PLATFORM = linux/arm64
-else
-PLATFORM = linux/amd64
-endif
-
-.PHONY: image
-image: ## Build a local image without publishing artifacts.
- $(MAKE) build GOOS=linux
- $(call print-target)
- $(DOCKER) buildx build --file=$(DOCKERFILE) \
- --platform=$(PLATFORM) \
- --build-arg VERSION=$(VERSION) \
- --build-arg REVISION=$(REVISION) \
- --build-arg BUILDDATE=$(BUILDDATE) \
- --tag $(LOCAL_REPO) \
- --load \
- .
-
-.PHONY: push
-push: ## Publish to container registry.
- $(call print-target)
- $(DOCKER) tag $(LOCAL_REPO) $(DOCKER_REPO):v$(VERSION)-$(subst /,-,$(PLATFORM))
- $(DOCKER) push $(DOCKER_REPO):v$(VERSION)-$(subst /,-,$(PLATFORM))
-
-.PHONY: test-image
-test-image: ## Test local image
- $(call print-target)
- $(DOCKER) run --platform=$(PLATFORM) --rm -t $(LOCAL_REPO) -v
-
define print-target
@$(PRINTF) "Executing target: \033[36m$@\033[0m\n"
endef
diff --git a/Makefile.ps1 b/Makefile.ps1
index 2f3c186..14851ff 100755
--- a/Makefile.ps1
+++ b/Makefile.ps1
@@ -26,7 +26,6 @@ foreach ($arg in $args) {
}
}
-if (-not $env:DOCKER) { $env:DOCKER = "docker" }
if (-not $env:GO) { $env:GO = "go" }
if (-not $env:GORELEASER) { $env:GORELEASER = "goreleaser" }
@@ -65,47 +64,6 @@ else {
}
}
-function Get-Version {
- try {
- $exactMatch = git describe --tags --exact-match 2>$null
- if (-not [string]::IsNullOrEmpty($exactMatch)) {
- $version = $exactMatch
- }
- else {
- $tags = git describe --tags 2>$null;
- if ([string]::IsNullOrEmpty($tags)) {
- $commitHash = (git rev-parse --short=8 HEAD).Trim();
- $version = "0.0.0-0-g$commitHash"
- }
- else {
- $version = $tags -replace '-[0-9][0-9]*-g', '-SNAPSHOT-'
- }
- }
- $version = $version -replace '^v', ''
- return $version
- }
- catch {
- return "0.0.0"
- }
-}
-
-function Get-Revision {
- $revision = git rev-parse HEAD
- return $revision
-}
-
-function Get-Builddate {
- $datetime = Get-Date
- $utc = $datetime.ToUniversalTime()
- return $utc.tostring("yyyy-MM-ddTHH:mm:ssZ")
-}
-
-if (-not $env:VERSION) { $env:VERSION = (& get-version) }
-if (-not $env:REVISION) { $env:REVISION = (& get-revision) }
-if (-not $env:BUILDDATE) { $env:BUILDDATE = (& get-builddate) }
-
-if (-not $env:CGO_ENABLED) { $env:CGO_ENABLED = "0" }
-
function Invoke-CommandWithEcho {
param (
[string]$Command,
@@ -138,13 +96,9 @@ function Write-Target {
## TARGET build Build app binary for single target
function Invoke-Target-Build {
Write-Target "build"
- Invoke-CommandWithEcho $env:GO -Arguments "build", "-trimpath", "-ldflags=`"-s -w -X main.version=$env:VERSION`""
-}
+ # $(GORELEASER) build --clean --snapshot --single-target --output $(BIN)
-## TARGET goreleaser Build app binary for all targets
-function Invoke-Target-Goreleaser {
- Write-Target "goreleaser"
- Invoke-CommandWithEcho $env:GORELEASER -Arguments "release", "--auto-snapshot", "--clean", "--skip-publish"
+ Invoke-CommandWithEcho $env:GORELEASER -Arguments "build", "--clean", "--snapshot", "--single-target", "--output", $env:BIN
}
## TARGET install Build and install app binary
@@ -188,72 +142,6 @@ function Invoke-Target-Clean {
Invoke-ExpressionWithEcho -Command "Remove-Item dist -Recurse -Force -ErrorAction SilentlyContinue"
}
-## TARGET version Show version
-function Invoke-Target-Version {
- Write-Host $env:VERSION
-}
-
-## TARGET revision Show revision
-function Invoke-Target-Revision {
- Write-Host $env:REVISION
-}
-
-## TARGET builddate Show build date
-function Invoke-Target-Builddate {
- Write-Host $env:BUILDDATE
-}
-
-if (-not $env:DOCKERFILE) { $env:DOCKERFILE = "Dockerfile" }
-if (-not $env:IMAGE_NAME) { $env:IMAGE_NAME = $env:BIN }
-if (-not $env:LOCAL_REPO) { $env:LOCAL_REPO = "localhost:5000/$env:IMAGE_NAME" }
-if (-not $env:DOCKER_REPO) { $env:DOCKER_REPO = "localhost:5000/$env:IMAGE_NAME" }
-
-if (-not $env:PLATFORM) {
- if ($env:PROCESSOR_ARCHITECTURE -eq "ARM64") {
- $env:PLATFORM = "linux/arm64"
- }
- elseif ((uname -m) -eq "arm64") {
- $env:PLATFORM = "linux/arm64"
- }
- elseif ((uname -m) -eq "aarch64") {
- $env:PLATFORM = "linux/arm64"
- }
- elseif ((uname -s) -match "ARM64") {
- $env:PLATFORM = "linux/arm64"
- }
- else {
- $env:PLATFORM = "linux/amd64"
- }
-}
-
-## TARGET image Build a local image without publishing artifacts.
-function Invoke-Target-Image {
- $env:GOOS = "linux"
- Invoke-Target-Build
- Write-Target "image"
- Invoke-CommandWithEcho $env:DOCKER -Arguments "buildx", "build", "--file=$env:DOCKERFILE",
- "--platform=$env:PLATFORM",
- "--build-arg", "VERSION=$env:VERSION",
- "--build-arg", "REVISION=$env:REVISION",
- "--build-arg", "BUILDDATE=$env:BUILDDATE",
- "--tag", $env:LOCAL_REPO,
- "--load",
- "."
-}
-
-## TARGET push Publish to container registry.
-function Invoke-Target-Push {
- Write-Target "push"
- Invoke-CommandWithEcho $env:DOCKER -Arguments "tag", $env:LOCAL_REPO, "$($env:DOCKER_REPO):v$($env:VERSION)-$($env:PLATFORM -replace '/','-')"
- Invoke-CommandWithEcho $env:DOCKER -Arguments "push", "$($env:DOCKER_REPO):v$($env:VERSION)-$($env:PLATFORM -replace '/','-')"
-}
-
-## TARGET test-image Test local image
-function Invoke-Target-Test-Image {
- Write-Target "test-image"
- Invoke-CommandWithEcho $env:DOCKER -Arguments "run", "--platform=$env:PLATFORM", "--rm", "-t", $env:LOCAL_REPO, "-v"
-}
-
function Invoke-Target-Help {
Write-Host "Targets:"
Get-Content $PSCommandPath |
diff --git a/dist/artifacts.json b/dist/artifacts.json
new file mode 100644
index 0000000..3c6863b
--- /dev/null
+++ b/dist/artifacts.json
@@ -0,0 +1 @@
+[{"name":"tf","path":"dist/tf_darwin_arm64/tf","goos":"darwin","goarch":"arm64","internal_type":4,"type":"Binary","extra":{"Binary":"tf","Ext":"","ID":"tf"}}]
\ No newline at end of file
diff --git a/dist/config.yaml b/dist/config.yaml
new file mode 100644
index 0000000..5940917
--- /dev/null
+++ b/dist/config.yaml
@@ -0,0 +1,110 @@
+project_name: tf
+release:
+ github:
+ owner: dex4er
+ name: tf
+ name_template: '{{.Tag}}'
+builds:
+ - id: tf
+ goos:
+ - darwin
+ goarch:
+ - arm64
+ goarm:
+ - "6"
+ gomips:
+ - hardfloat
+ goamd64:
+ - v1
+ targets:
+ - darwin_arm64
+ dir: .
+ main: .
+ binary: tf
+ builder: go
+ gobinary: go
+ command: build
+ ldflags:
+ - -s -w -X main.version={{.Version}} -X main.commit={{.Commit}} -X main.date={{.Date}} -X main.builtBy=goreleaser
+ flags:
+ - -trimpath
+ env:
+ - CGO_ENABLED=0
+archives:
+ - id: default
+ name_template: '{{ .ProjectName }}-{{ .Os }}-{{ .Arch }}'
+ format: binary
+ files:
+ - src: license*
+ - src: LICENSE*
+ - src: readme*
+ - src: README*
+ - src: changelog*
+ - src: CHANGELOG*
+snapshot:
+ name_template: '{{ .Version }}-SNAPSHOT-{{ .ShortCommit }}'
+checksum:
+ name_template: checksums.txt
+ algorithm: sha256
+changelog:
+ use: github
+dist: dist
+env_files:
+ github_token: ~/.config/goreleaser/github_token
+ gitlab_token: ~/.config/goreleaser/gitlab_token
+ gitea_token: ~/.config/goreleaser/gitea_token
+before:
+ hooks:
+ - go mod download
+source:
+ name_template: '{{ .ProjectName }}-{{ .Version }}'
+ format: tar.gz
+gomod:
+ gobinary: go
+announce:
+ twitter:
+ message_template: '{{ .ProjectName }} {{ .Tag }} is out! Check it out at {{ .ReleaseURL }}'
+ mastodon:
+ message_template: '{{ .ProjectName }} {{ .Tag }} is out! Check it out at {{ .ReleaseURL }}'
+ server: ""
+ reddit:
+ title_template: '{{ .ProjectName }} {{ .Tag }} is out!'
+ url_template: '{{ .ReleaseURL }}'
+ slack:
+ message_template: '{{ .ProjectName }} {{ .Tag }} is out! Check it out at {{ .ReleaseURL }}'
+ username: GoReleaser
+ discord:
+ message_template: '{{ .ProjectName }} {{ .Tag }} is out! Check it out at {{ .ReleaseURL }}'
+ author: GoReleaser
+ color: "3888754"
+ icon_url: https://goreleaser.com/static/avatar.png
+ teams:
+ title_template: '{{ .ProjectName }} {{ .Tag }} is out!'
+ message_template: '{{ .ProjectName }} {{ .Tag }} is out! Check it out at {{ .ReleaseURL }}'
+ color: '#2D313E'
+ icon_url: https://goreleaser.com/static/avatar.png
+ smtp:
+ subject_template: '{{ .ProjectName }} {{ .Tag }} is out!'
+ body_template: 'You can view details from: {{ .ReleaseURL }}'
+ mattermost:
+ message_template: '{{ .ProjectName }} {{ .Tag }} is out! Check it out at {{ .ReleaseURL }}'
+ title_template: '{{ .ProjectName }} {{ .Tag }} is out!'
+ username: GoReleaser
+ linkedin:
+ message_template: '{{ .ProjectName }} {{ .Tag }} is out! Check it out at {{ .ReleaseURL }}'
+ telegram:
+ message_template: '{{ .ProjectName }} {{ mdv2escape .Tag }} is out! Check it out at {{ mdv2escape .ReleaseURL }}'
+ parse_mode: MarkdownV2
+ webhook:
+ message_template: '{ "message": "{{ .ProjectName }} {{ .Tag }} is out! Check it out at {{ .ReleaseURL }}"}'
+ content_type: application/json; charset=utf-8
+ opencollective:
+ title_template: '{{ .Tag }}'
+ message_template: '{{ .ProjectName }} {{ .Tag }} is out!
Check it out at {{ .ReleaseURL }}'
+git:
+ tag_sort: -version:refname
+force_token: github
+github_urls:
+ download: https://github.com
+gitlab_urls:
+ download: https://gitlab.com
diff --git a/dist/metadata.json b/dist/metadata.json
new file mode 100644
index 0000000..0eaad48
--- /dev/null
+++ b/dist/metadata.json
@@ -0,0 +1 @@
+{"project_name":"tf","tag":"v2.9.0","previous_tag":"v2.8.1","version":"2.9.0-SNAPSHOT-343852d","commit":"343852dc6f17879cac2eba578daf6bbe6e9b1dbb","date":"2024-02-14T23:54:04.893912+01:00","runtime":{"goos":"darwin","goarch":"arm64"}}
\ No newline at end of file