diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..fe87f5b --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,54 @@ +name: Release Please + +on: + push: + branches: + - main + +permissions: + contents: write + pull-requests: write + +jobs: + release: + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Set up Go + uses: actions/setup-go@v5 + with: + go-version: '1.22.0' + + - name: Install dependencies + run: go mod tidy + + - name: Run Release Please + id: release + uses: GoogleCloudPlatform/release-please-action@v4 + with: + release-type: go + package-name: analyzer + + # Skip build & upload if no new release was created + - name: Check if release was created + if: ${{ steps.release.outputs.release_created != 'true' }} + run: echo "No release created, skipping binary build." && exit 0 + + - name: Build binaries + run: make build-all + + - name: Generate checksums + run: | + cd bin + sha256sum * > checksums.txt + + - name: Upload Release Assets + uses: softprops/action-gh-release@v2 + with: + files: | + bin/analyzer-* + bin/checksums.txt + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file diff --git a/Makefile b/Makefile index 00d6629..4188877 100644 --- a/Makefile +++ b/Makefile @@ -1,9 +1,26 @@ GOLANGCI := $(GOPATH)/bin/golangci-lint +APP_NAME := analyzer +BUILD_DIR := bin +PLATFORMS := \ + linux/amd64 \ + linux/arm64 \ + darwin/amd64 \ + darwin/arm64 \ + windows/amd64 +BINARIES := $(foreach platform,$(PLATFORMS),$(BUILD_DIR)/$(APP_NAME)-$(subst /,-,$(platform))) .PHONY: analyzer analyzer: go build -o ./bin/analyzer ./main.go +.PHONY: build-all +build-all: $(BINARIES) + +$(BUILD_DIR)/$(APP_NAME)-%: + @mkdir -p $(BUILD_DIR) + @GOOS=$(word 1,$(subst -, ,$*)) GOARCH=$(word 2,$(subst -, ,$*)) go build -o $@ ./main.go + @echo "Built $@" + .PHONY: get get: go mod download && go mod tidy