diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 6548fe7..a802c71 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -114,29 +114,9 @@ jobs: with: args: ./... - # create-dummy-release: - # needs: [ prepare, test, code_scans ] - # name: Create empty release - # runs-on: ubuntu-latest - # steps: - # - name: Checkout repo - # uses: actions/checkout@v3 - # - name: Get list of the commits since last release - # run: | - # echo "$(git log $(git describe --tags --abbrev=0)..HEAD --pretty=format:"%h %s")" > .release_notes - # - name: Create empty release - # uses: ncipollo/release-action@v1 - # with: - # bodyFile: ./.release_notes - # name: version ${{ needs.prepare.outputs.RELEASE_VERSION }} - # token: ${{ secrets.GHCR_TOKEN }} - # tag: ${{ needs.prepare.outputs.RELEASE_VERSION }} - # prerelease: ${{ github.ref != 'refs/heads/master' && github.ref != 'refs/heads/main' }} - # allowUpdates: true - - build: + build-docker: needs: [ prepare, test, code_scans ] - name: Docker image build (regular:multiarch) + name: Docker image build runs-on: ubuntu-latest steps: - name: Checkout repo @@ -211,20 +191,40 @@ jobs: steps: - name: Checkout code uses: actions/checkout@v3 - with: - fetch-depth: 0 - name: Install Go uses: actions/setup-go@v3 with: go-version: ${{ env.GO_VERSION }} - - - name: Compile and release semver - uses: goreleaser/goreleaser-action@v4 + - name: Build binaries + run: | + LOCAL_VERSION=${{ needs.prepare.outputs.RELEASE_VERSION }} make dist-release + - name: Upload binaries + uses: actions/upload-artifact@v2 with: - version: latest - args: release --rm-dist --skip-validate --skip-publish --skip-sign - env: - GITHUB_TOKEN: ${{ secrets.GHCR_TOKEN }} + name: binaries + path: dist/ + + create-release: + needs: [ build-binary, build-docker ] + name: Create empty release + runs-on: ubuntu-latest + steps: + - name: Checkout repo + uses: actions/checkout@v3 + - name: Get list of the commits since last release + run: | + echo "$(git log $(git describe --tags --abbrev=0)..HEAD --pretty=format:"%h %s")" > .release_notes + - name: Create release + uses: ncipollo/release-action@v1 + with: + bodyFile: ./.release_notes + name: version ${{ needs.prepare.outputs.RELEASE_VERSION }} + token: ${{ secrets.GHCR_TOKEN }} + tag: ${{ needs.prepare.outputs.RELEASE_VERSION }} + prerelease: ${{ github.ref != 'refs/heads/master' && github.ref != 'refs/heads/main' }} + artifacts: "dist/*" + allowUpdates: true + # - name: Compile and release semver # uses: wangyoucao577/go-release-action@v1.34 # with: diff --git a/.gitignore b/.gitignore index 92d7c40..1d2dae0 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,4 @@ semver-gen -coverage.out \ No newline at end of file +coverage.out +.vscode +.DS_Store \ No newline at end of file diff --git a/.goreleaser.yaml b/.goreleaser.yaml deleted file mode 100644 index b058b87..0000000 --- a/.goreleaser.yaml +++ /dev/null @@ -1,30 +0,0 @@ -builds: - - - ldflags: - - -s -w -X main.PKG_VERSION={{.Version}} - env: - - CGO_ENABLED=0 - - GO111MODULE=on - - >- - {{- if eq .Os "darwin" }} - GOOS=darwin - GOARCH={{ .Arch }} - # - >- - # {{- if eq .Os "darwin" }} - # {{- if eq .Arch "amd64"}}CC=o64-clang{{- end }} - # {{- if eq .Arch "arm64"}}CC=aarch64-apple-darwin20.2-clang{{- end }} - # {{- end }} - # {{- if eq .Os "windows" }} - # {{- if eq .Arch "amd64" }}CC=x86_64-w64-mingw32-gcc{{- end }} - # {{- end }} - binary: semver-gen-{{ .Os }}-{{ .Arch }} - no_unique_dist_dir: true - # buildmode: c-shared - builder: go - ignore: - - goos: windows - goarch: 386 - - goos: windows - goarch: arm64 - - goos: windows - goarch: amd64 \ No newline at end of file diff --git a/Makefile b/Makefile index e7fe081..81315f0 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,7 @@ LOCAL_VERSION?="" CI_RUN?=false ADDITIONAL_BUILD_FLAGS="" +LDFLAGS=-s -w -X main.PKG_VERSION=${LOCAL_VERSION} ifeq ($(CI_RUN), true) ADDITIONAL_BUILD_FLAGS="-test.short" @@ -38,3 +39,12 @@ update: ## Update dependencies .PHONY: update-all update-all: ## Update all dependencies and sub-packages @go get -u ./... + +dist-release: ## Build all binaries + rm -fr dist/ || true + mkdir -p dist/ + CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags $(LDFLAGS) -a -installsuffix cgo -o dist/semver-gen-linux-amd64 + CGO_ENABLED=0 GOOS=linux GOARCH=arm64 go build -ldflags $(LDFLAGS) -a -installsuffix cgo -o dist/semver-gen-linux-arm64 + CGO_ENABLED=0 GOOS=darwin go build -ldflags $(LDFLAGS) -a -installsuffix cgo -o dist/semver-gen-darwin-amd64 + CGO_ENABLED=0 GOOS=darwin GOARCH=arm64 go build -ldflags $(LDFLAGS) -a -installsuffix cgo -o dist/semver-gen-darwin-arm64 + CGO_ENABLED=0 GOOS=windows GOARCH=amd64 go build -ldflags $(LDFLAGS) -a -installsuffix cgo -o dist/semver-gen-windows-amd64.exe \ No newline at end of file diff --git a/cmd/main.go b/cmd/main.go index 29485cf..25b3a7b 100644 --- a/cmd/main.go +++ b/cmd/main.go @@ -1,7 +1,3 @@ -// go:build (darwin && cgo) || linux -//go:build (darwin && cgo) || linux -// +build darwin,cgo linux - // Project: semver-generator /* Copyright © 2021 LUKASZ RACZYLO diff --git a/main.go b/main.go index 3b06ab1..030d0a8 100644 --- a/main.go +++ b/main.go @@ -1,8 +1,3 @@ -//go:build (darwin && cgo) || linux -// +build darwin,cgo linux - -// Project: semver-generator -// go:build (darwin && cgo) || linux /* Copyright © 2021 LUKASZ RACZYLO