Skip to content

Commit

Permalink
ci(release): make zip for windows release
Browse files Browse the repository at this point in the history
  • Loading branch information
mrmoneyc committed Oct 17, 2022
1 parent fe7cd69 commit 535e17e
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,6 @@ jobs:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: dist/${{ steps.get_version.outputs.VERSION }}/slack-exporter-${{ steps.get_version.outputs.VERSION }}-windows-amd64.tar.gz
asset_name: slack-exporter-${{ steps.get_version.outputs.VERSION }}-windows-amd64.tar.gz
asset_path: dist/${{ steps.get_version.outputs.VERSION }}/slack-exporter-${{ steps.get_version.outputs.VERSION }}-windows-amd64.zip
asset_name: slack-exporter-${{ steps.get_version.outputs.VERSION }}-windows-amd64.zip
asset_content_type: application/octet-stream
12 changes: 10 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ VERSION ?= $(shell git describe --tags --always --dirty --match=v* 2> /dev/null
cat $(CURDIR)/.version 2> /dev/null || echo nightly)
BIN_DIR = $(CURDIR)/bin
DIST_DIR ?= $(CURDIR)/dist
SCRIPT_DIR = $(CURDIR)/scripts
WINDOWS_RUN = run.bat

GO = go

Expand Down Expand Up @@ -52,7 +54,7 @@ dist-darwin: \
$(DIST_DIR)/$(VERSION)/$(BIN)-$(VERSION)-darwin-amd64.tar.gz

dist-windows: \
$(DIST_DIR)/$(VERSION)/$(BIN)-$(VERSION)-windows-amd64.tar.gz
$(DIST_DIR)/$(VERSION)/$(BIN)-$(VERSION)-windows-amd64.zip

## Generate dist archive file
dist: dist-linux dist-darwin dist-windows
Expand All @@ -68,14 +70,20 @@ $(DIST_DIR)/$(VERSION):
$(DIST_DIR)/$(VERSION)/$(BIN)-$(VERSION)-%.tar.gz: build-% $(DIST_DIR)/$(VERSION)
tar -C $(BIN_DIR) -cvzf $@ $(BIN)-$*

$(DIST_DIR)/$(VERSION)/$(BIN)-$(VERSION)-windows-%.zip: build-windows-% $(DIST_DIR)/$(VERSION)
cp $(SCRIPT_DIR)/$(WINDOWS_RUN) $(BIN_DIR)/$(WINDOWS_RUN)
cd $(BIN_DIR) && zip -r $@ $(BIN).exe $(WINDOWS_RUN)

build-%: $(BIN_DIR) ; $(info $(M) Building $(BIN)-$*...)
$Q os=$$(echo $* | cut -d "-" -f 1); \
arch=$$(echo $* | cut -d "-" -f 2); \
if [ "$$os" != "$$arch" ]; then \
output=$(BIN_DIR)/$(BIN)-$*; \
[[ "$$os" == "windows" ]] && output=$(BIN_DIR)/$(BIN).exe; \
GOOS=$$os GOARCH=$$arch $(GO) build \
-tags release \
-ldflags '-X $(PACKAGE)/pkg/cmd.Version=$(VERSION) -X $(PACKAGE)/pkg/cmd.BuildDate=$(DATE)' \
-o $(BIN_DIR)/$(BIN)-$* cmd/slack-exporter/main.go; \
-o $$output cmd/slack-exporter/main.go; \
fi

# Misc
Expand Down

0 comments on commit 535e17e

Please sign in to comment.