Skip to content

Commit

Permalink
feat:support windows runners (#25)
Browse files Browse the repository at this point in the history
* feat: add wrapper script

* feat: add builds

* fix(wrapper): binary directory

* chore(wrapper): add warning

* fix(wrapper): args input

* chore(wrapper): remove input warning

* fix(wrapper): read assets permission denied

* chore(wrapper): warn only on wrong configuration

* chore: bump version
  • Loading branch information
anton-yurchenko authored Jun 27, 2020
1 parent 6b32778 commit 59dc277
Show file tree
Hide file tree
Showing 19 changed files with 769 additions and 42 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@
# project
coverage.txt
/vendor/
/release/
package-lock.json
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
## [3.3.0] - 2020-06-27
### Added
- Wrapper script: allow execution on Windows runners

### Changed
- Action execution through Git: from Docker to NodeJS

## [3.2.0] - 2020-06-04
### Fixed
- Ignored `ALLOW_EMPTY_CHANGELOG=true` failed to create a release.
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ RUN CGO_ENABLED=0 go build -ldflags="-w -s" -o /opt/app
FROM scratch
LABEL "repository"="https://github.com/anton-yurchenko/git-release"
LABEL "maintainer"="Anton Yurchenko <[email protected]>"
LABEL "version"="3.2.0"
LABEL "version"="3.3.0"
COPY --from=build /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/
COPY --from=build /etc/passwd /etc/passwd
COPY LICENSE.md /LICENSE.md
Expand Down
18 changes: 12 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# global
BINARY := $(notdir $(CURDIR))
GO_BIN_DIR := $(GOPATH)/bin
OSES := windows
OSES := windows linux
ARCHS := amd64

# unit tests
Expand Down Expand Up @@ -32,20 +32,26 @@ $(GO_LINTER):
@echo "installing linter..."
go get -u github.com/golangci/golangci-lint/cmd/golangci-lint

.PHONY: release
release: test
.PHONY: build
build: test
@rm -rf ./release
@mkdir -p release
@for ARCH in $(ARCHS); do \
for OS in $(OSES); do \
if test "$$OS" = "windows"; then \
GOOS=$$OS GOARCH=$$ARCH go build -o release/$(BINARY)-$$OS-$$ARCH.exe; \
GOOS=$$OS GOARCH=$$ARCH go build -o build/$(BINARY)-$$OS-$$ARCH.exe; \
else \
GOOS=$$OS GOARCH=$$ARCH go build -o release/$(BINARY)-$$OS-$$ARCH; \
GOOS=$$OS GOARCH=$$ARCH go build -o build/$(BINARY)-$$OS-$$ARCH; \
fi; \
done; \
done

.PHONY: codecov
codecov: test
@go tool cover -html=coverage.txt
@go tool cover -html=coverage.txt

.PHONY: release
release: build
@git push
@git tag $(tag)
@git push --tags
43 changes: 17 additions & 26 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,42 +83,33 @@ on:

<details><summary>:information_source: Execute on Windows runner</summary>

In case you need to execute 'git-release' directly from a Windows Runner, you may do that by downloading the binary and running it directly.
In case you need to execute 'git-release' from a Windows Runner, you may do that by running the action through JavaScript runner.

Example:
```
- name: Release
shell: pwsh
run: |
Write-Host "Downloading latest 'git-release' windows binary..."
Invoke-WebRequest $( `
Invoke-RestMethod -uri https://api.github.com/repos/anton-yurchenko/git-release/releases/latest | `
select -ExpandProperty assets | `
select -expand browser_download_url | `
where { $_.Contains("windows-amd64") -eq $true }) `
-OutFile ./git-release.exe
Write-Host "Creating a GitHub Release..."
$env:GITHUB_TOKEN = '${{ secrets.GITHUB_TOKEN }}'; `
$env:DRAFT_RELEASE = 'false'; `
$env:PRE_RELEASE = 'false'; `
$env:CHANGELOG_FILE = 'CHANGELOG.md'; `
$env:ALLOW_EMPTY_CHANGELOG = 'false'; `
$env:ALLOW_TAG_PREFIX = 'true'; `
./git-release.exe `
build/darwin-amd64.zip `
build/linux-amd64.zip `
build/windows-amd64.zip
- name: Release
uses: anton-yurchenko/git-release@master
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
DRAFT_RELEASE: "false"
PRE_RELEASE: "false"
CHANGELOG_FILE: "CHANGELOG.md"
ALLOW_EMPTY_CHANGELOG: "false"
ALLOW_TAG_PREFIX: "true"
with:
args: |
build/darwin-amd64.zip
build/linux-amd64.zip
build/windows-amd64.zip
```
- Provide the configuration in exactly the same manner to the binary as to docker container, environmental variables and arguments.

</details>

## Remarks:
- **Git Tag** should be identical to **Changelog Version** in order for changes to be parsed properly. This does not include **Tag Prefix** like `v*`.
- This action is automatically built at **Docker Hub**, and tagged with `latest / v3 / v3.2 / v3.2.0`. You may lock to a certain version instead of using **latest**.
- This action is automatically built at **Docker Hub**, and tagged with `latest / v3 / v3.3 / v3.3.0`. You may lock to a certain version instead of using **latest**.
(*Recommended to lock against a major version, for example* `v3`)
- Instead of using pre-built image, you may build it during the execution of your flow by changing `docker://antonyurchenko/git-release:latest` to `anton-yurchenko/git-release@master`
- Instead of using a pre-built Docker image, you may execute the action through JavaScript wrapper by changing `docker://antonyurchenko/git-release:latest` to `anton-yurchenko/git-release@master`

## License
[MIT](LICENSE.md) © 2019-present Anton Yurchenko
16 changes: 10 additions & 6 deletions action.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
name: 'Git Release'
description: 'Create a GitHub Release with Assets and Changelog'
name: "Git Release"
description: "Create a GitHub Release with Assets and Changelog"
branding:
icon: 'tag'
color: 'black'
icon: "tag"
color: "black"
inputs:
args:
description: "Release Assets"
required: false
runs:
using: 'docker'
image: 'Dockerfile'
using: "node12"
main: "wrapper.js"
Binary file added build/git-release-linux-amd64
Binary file not shown.
Binary file added build/git-release-windows-amd64.exe
Binary file not shown.
2 changes: 0 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@ github.com/spf13/afero v1.2.2/go.mod h1:9ZxEEn6pIJ8Rxe320qSDBk6AsU0r9pR7Q4OcevTd
github.com/stretchr/objx v0.1.0 h1:4G4v2dO3VZwixGIRoQ5Lfboy6nUhCyYzaqnIAPPhYs4=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
github.com/stretchr/testify v1.6.0 h1:jlIyCplCJFULU/01vCkhKuTyc3OorI3bJFuw6obfgho=
github.com/stretchr/testify v1.6.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/stretchr/testify v1.6.1 h1:hDPOHmpOpP40lSULcqw7IrRb/u7w6RpDC9399XyoNd0=
github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
Expand Down
146 changes: 146 additions & 0 deletions node_modules/@actions/core/README.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

21 changes: 21 additions & 0 deletions node_modules/@actions/core/lib/command.d.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 59dc277

Please sign in to comment.