Skip to content

Commit

Permalink
Merge pull request #110 from doitintl/feature/windowsRelease
Browse files Browse the repository at this point in the history
feat: Windows release
  • Loading branch information
stepanstipl authored Apr 1, 2021
2 parents 693ba75 + f67adc6 commit a011986
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 22 deletions.
51 changes: 30 additions & 21 deletions .github/workflows/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,12 @@ jobs:
scripts/alpine-setup.sh
make test
build:
name: Build
name: build
runs-on: ubuntu-latest
container: golang:1.16.2-alpine3.12
strategy:
matrix:
os: [linux, darwin, windows]
steps:
- name: Checkout
uses: actions/checkout@v1
Expand All @@ -38,26 +41,26 @@ jobs:
- name: Build
run: |
scripts/alpine-setup.sh
GOOS=darwin GOARCH=amd64 make all
GOOS=linux GOARCH=amd64 make all
GOOS=${{ matrix.os }} GOARCH=amd64 make all
make changelog
shell: sh
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Archive release artifacts
uses: actions/upload-artifact@v1
with:
name: release-artifacts
name: release-artifacts-${{ matrix.os }}
path: release-artifacts
release:
name: Release
needs: build
create-release:
name: Create Release
needs:
[test, pre-commit, build]
runs-on: ubuntu-latest
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')
steps:
- uses: actions/download-artifact@v1
with:
name: release-artifacts
name: release-artifacts-linux
path: release-artifacts
- name: Get the tag
id: get_tag
Expand All @@ -73,23 +76,29 @@ jobs:
body_path: ./release-artifacts/changelog.md
draft: ${{ startsWith(steps.get_tag.outputs.git_tag, 'nightly') != true }}
prerelease: ${{ startsWith(steps.get_tag.outputs.git_tag, 'nightly') }}
- name: Upload Release Asset - Mac
id: upload-release-asset-mac
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
release-artifacts:
name: Relase Artifacts
needs:
[create-release]
runs-on: ubuntu-latest
strategy:
matrix:
os: [linux, darwin, windows]
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')
steps:
- uses: actions/download-artifact@v1
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./release-artifacts/kubent-${{ steps.get_tag.outputs.git_tag }}-darwin-amd64.tar.gz
asset_name: kubent-${{ steps.get_tag.outputs.git_tag }}-darwin-amd64.tar.gz
asset_content_type: application/tar+gzip
- name: Upload Release Asset - Linux
id: upload-release-asset-linux
name: release-artifacts-${{ matrix.os }}
path: release-artifacts
- name: Get the tag
id: get_tag
run: echo ::set-output name=git_tag::${GITHUB_REF/refs\/tags\//}
- name: Upload Release Asset - ${{ matrix.os }}
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./release-artifacts/kubent-${{ steps.get_tag.outputs.git_tag }}-linux-amd64.tar.gz
asset_name: kubent-${{ steps.get_tag.outputs.git_tag }}-linux-amd64.tar.gz
asset_path: ./release-artifacts/kubent-${{ steps.get_tag.outputs.git_tag }}-${{ matrix.os }}-amd64.tar.gz
asset_name: kubent-${{ steps.get_tag.outputs.git_tag }}-${{ matrix.os }}-amd64.tar.gz
asset_content_type: application/tar+gzip
7 changes: 6 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@ ifneq (3.82,$(firstword $(sort $(MAKE_VERSION) 3.82)))
$(error This Make does not support .ONESHELL, use GNU Make 3.82 and newer)
endif

ifeq (windows,$(GOOS))
BIN_RELEASE_SUFFIX ?= .exe
endif
BIN_RELEASE_SUFFIX ?=

.DEFAULT_GOAL :=help

GITHUB_REF ?= dev
Expand Down Expand Up @@ -85,7 +90,7 @@ release-artifacts: $(RELEASE_ARTIFACTS)

$(RELEASE_DIR)/%-$(RELEASE_SUFFIX): $(PACKED_DIR)/%-$(BIN_ARCH)
mkdir -p $(RELEASE_DIR)
$(TAR) -cvz --transform 's,$(PACKED_DIR)/$(*)-$(BIN_ARCH),$(*),gi' -f "$@" "$<"
$(TAR) -cvz --transform 's,$(PACKED_DIR)/$(*)-$(BIN_ARCH),$(*)$(BIN_RELEASE_SUFFIX),gi' -f "$@" "$<"

## Run Go tests
test: test-fmt test-git
Expand Down

0 comments on commit a011986

Please sign in to comment.