mirror of
https://github.com/goreleaser/goreleaser-action
synced 2026-08-29 20:38:27 +00:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
44b6852272 | ||
|
|
aff4fc5a2c | ||
|
|
c30b077d74 | ||
|
|
3b7a8e97ab | ||
|
|
10511362f8 | ||
|
|
62b67a060c | ||
|
|
de0cc32957 | ||
|
|
07505093f2 | ||
|
|
de0090dcf9 | ||
|
|
56a17acc58 | ||
|
|
e9d8a486b9 | ||
|
|
1de7ab1241 | ||
|
|
da499dc8c4 | ||
|
|
bf5c0312ba | ||
|
|
30f55a5465 | ||
|
|
46fecbc374 | ||
|
|
e2e0026788 | ||
|
|
c782db219c | ||
|
|
e4f3e46c3a | ||
|
|
354ab336f2 | ||
|
|
aa45e0b3de | ||
|
|
3fc0ad887b | ||
|
|
5ea6f8cff6 | ||
|
|
408809cf2e | ||
|
|
5df9eaf51a | ||
|
|
2f7115b6eb | ||
|
|
6e289c036a | ||
|
|
8d2d6e23ba | ||
|
|
e3e8938134 | ||
|
|
aa1fbb5b7f | ||
|
|
0122c3b611 | ||
|
|
32c621e48f | ||
|
|
d922612e4f | ||
|
|
4f52b7bd4b | ||
|
|
5067175657 | ||
|
|
1723202839 | ||
|
|
277675f877 | ||
|
|
a9021ad9f8 | ||
|
|
551f7d8a6c | ||
|
|
849d1c01b1 | ||
|
|
ac187d128a | ||
|
|
108bc4da5a | ||
|
|
92b29cc8ff | ||
|
|
87487e9bbd | ||
|
|
99636ee53c | ||
|
|
3140f0a474 | ||
|
|
83d17e5b70 | ||
|
|
3fa258510f | ||
|
|
17a723793e | ||
|
|
0c93efcb3b | ||
|
|
bfee8df61e | ||
|
|
65ffe9d1d5 | ||
|
|
145323343f | ||
|
|
c2638bf40c | ||
|
|
f3c3945401 | ||
|
|
b965206285 | ||
|
|
5ee2a593ae | ||
|
|
92dbfe88d3 | ||
|
|
5c72929026 | ||
|
|
6cda5a63f1 | ||
|
|
85e5a36a01 | ||
|
|
5835168d00 | ||
|
|
4cd8fafb4f | ||
|
|
6c7b10c265 | ||
|
|
88f1da8c86 | ||
|
|
2555b3b392 | ||
|
|
7d241840cb | ||
|
|
8a2a131059 | ||
|
|
6bbaec719e | ||
|
|
d139f5173c | ||
|
|
97ac0d8773 | ||
|
|
370c46a5bb | ||
|
|
2f9f2a7ad1 | ||
|
|
29e97dc85b | ||
|
|
7a8bdf9c3a | ||
|
|
d0cfadc807 | ||
|
|
8afea26b30 | ||
|
|
d2079604fb | ||
|
|
86bb25eb16 | ||
|
|
118c74acdb | ||
|
|
bfdefad7a0 | ||
|
|
82db7ce7a9 | ||
|
|
25477b1bd1 | ||
|
|
1066259677 | ||
|
|
0104c038fa | ||
|
|
f3bdd39e1f | ||
|
|
db99dcc9b2 | ||
|
|
fb949a3789 | ||
|
|
bc41bde3ee | ||
|
|
a49693e423 | ||
|
|
62c27dd156 |
@@ -0,0 +1,20 @@
|
||||
version: 2
|
||||
updates:
|
||||
- package-ecosystem: "github-actions"
|
||||
directory: "/"
|
||||
schedule:
|
||||
interval: "daily"
|
||||
time: "06:00"
|
||||
timezone: "Europe/Paris"
|
||||
labels:
|
||||
- "dependencies"
|
||||
- package-ecosystem: "npm"
|
||||
directory: "/"
|
||||
schedule:
|
||||
interval: "daily"
|
||||
time: "06:00"
|
||||
timezone: "Europe/Paris"
|
||||
allow:
|
||||
- dependency-type: "production"
|
||||
labels:
|
||||
- "dependencies"
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 16 KiB |
@@ -1,49 +0,0 @@
|
||||
name: ci
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
branches:
|
||||
- master
|
||||
- releases/*
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
- releases/*
|
||||
|
||||
jobs:
|
||||
ci:
|
||||
runs-on: ${{ matrix.os }}
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
os:
|
||||
- ubuntu-latest
|
||||
- macOS-latest
|
||||
- windows-latest
|
||||
version:
|
||||
- latest
|
||||
- v0.117.0
|
||||
steps:
|
||||
-
|
||||
name: Checkout
|
||||
uses: actions/checkout@v2
|
||||
-
|
||||
name: Unshallow
|
||||
run: git fetch --prune --unshallow
|
||||
-
|
||||
name: Set up Go
|
||||
uses: actions/setup-go@v1
|
||||
with:
|
||||
go-version: 1.13.x
|
||||
-
|
||||
name: Check
|
||||
uses: ./
|
||||
with:
|
||||
version: ${{ matrix.version }}
|
||||
args: check --debug
|
||||
-
|
||||
name: GoReleaser
|
||||
uses: ./
|
||||
with:
|
||||
version: ${{ matrix.version }}
|
||||
args: release --skip-publish --rm-dist
|
||||
@@ -0,0 +1,94 @@
|
||||
name: ci
|
||||
|
||||
on:
|
||||
schedule:
|
||||
- cron: '0 10 * * *' # everyday at 10am
|
||||
pull_request:
|
||||
branches:
|
||||
- master
|
||||
- releases/v*
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
- releases/v*
|
||||
|
||||
jobs:
|
||||
ci:
|
||||
runs-on: ${{ matrix.os }}
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
os:
|
||||
- ubuntu-latest
|
||||
- macOS-latest
|
||||
- windows-latest
|
||||
version:
|
||||
- latest
|
||||
- v0.117.0
|
||||
steps:
|
||||
-
|
||||
name: Checkout
|
||||
uses: actions/checkout@v2
|
||||
with:
|
||||
fetch-depth: 0
|
||||
-
|
||||
name: Set up Go
|
||||
uses: actions/setup-go@v2
|
||||
with:
|
||||
go-version: 1.14
|
||||
-
|
||||
name: Check
|
||||
uses: ./
|
||||
with:
|
||||
version: ${{ matrix.version }}
|
||||
args: check --debug
|
||||
-
|
||||
name: GoReleaser
|
||||
uses: ./
|
||||
with:
|
||||
version: ${{ matrix.version }}
|
||||
args: release --skip-publish --rm-dist
|
||||
|
||||
signing:
|
||||
runs-on: ${{ matrix.os }}
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
os:
|
||||
- ubuntu-latest
|
||||
- macOS-latest
|
||||
- windows-latest
|
||||
steps:
|
||||
-
|
||||
name: Checkout
|
||||
uses: actions/checkout@v2
|
||||
with:
|
||||
fetch-depth: 0
|
||||
-
|
||||
name: Set up Go
|
||||
uses: actions/setup-go@v2
|
||||
with:
|
||||
go-version: 1.14
|
||||
-
|
||||
name: Import GPG key
|
||||
id: import_gpg
|
||||
uses: crazy-max/ghaction-import-gpg@v2
|
||||
env:
|
||||
GPG_PRIVATE_KEY: ${{ secrets.GPG_PRIVATE_KEY_TEST }}
|
||||
PASSPHRASE: ${{ secrets.PASSPHRASE_TEST }}
|
||||
-
|
||||
name: Check
|
||||
uses: ./
|
||||
with:
|
||||
version: latest
|
||||
args: -f .goreleaser-signing.yml check --debug
|
||||
env:
|
||||
GPG_FINGERPRINT: ${{ steps.import_gpg.outputs.fingerprint }}
|
||||
-
|
||||
name: GoReleaser
|
||||
uses: ./
|
||||
with:
|
||||
version: latest
|
||||
args: -f .goreleaser-signing.yml release --skip-publish --rm-dist
|
||||
env:
|
||||
GPG_FINGERPRINT: ${{ steps.import_gpg.outputs.fingerprint }}
|
||||
@@ -1,22 +0,0 @@
|
||||
name: lint
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
paths:
|
||||
- '.github/workflows/lint.yml'
|
||||
- 'src/*'
|
||||
|
||||
jobs:
|
||||
lint:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
-
|
||||
# https://github.com/actions/checkout
|
||||
name: Checkout
|
||||
uses: actions/checkout@v1
|
||||
-
|
||||
name: Setup TS
|
||||
run: npm install tslint typescript -g
|
||||
-
|
||||
name: Lint check
|
||||
run: tslint './src/*.ts'
|
||||
@@ -0,0 +1,30 @@
|
||||
name: pre-checkin
|
||||
|
||||
on:
|
||||
push:
|
||||
paths-ignore:
|
||||
- '**.md'
|
||||
pull_request:
|
||||
paths-ignore:
|
||||
- '**.md'
|
||||
|
||||
jobs:
|
||||
pre-checkin:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
-
|
||||
name: Checkout
|
||||
uses: actions/checkout@v2
|
||||
-
|
||||
name: Install
|
||||
run: yarn install
|
||||
-
|
||||
name: Pre-checkin
|
||||
run: yarn run pre-checkin
|
||||
-
|
||||
name: Check for uncommitted changes
|
||||
run: |
|
||||
if [[ `git status --porcelain` ]]; then
|
||||
git status --porcelain
|
||||
echo "::warning::Found changes. Please run 'yarn run pre-checkin' and push"
|
||||
fi
|
||||
+26
-18
@@ -1,34 +1,42 @@
|
||||
name: test
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
branches:
|
||||
- master
|
||||
- releases/*
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
- releases/*
|
||||
- releases/v*
|
||||
paths-ignore:
|
||||
- '**.md'
|
||||
pull_request:
|
||||
paths-ignore:
|
||||
- '**.md'
|
||||
|
||||
jobs:
|
||||
test:
|
||||
runs-on: ubuntu-latest
|
||||
runs-on: ${{ matrix.os }}
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
os:
|
||||
- ubuntu-latest
|
||||
- macOS-latest
|
||||
- windows-latest
|
||||
steps:
|
||||
-
|
||||
# https://github.com/actions/checkout
|
||||
name: Checkout
|
||||
uses: actions/checkout@v1
|
||||
-
|
||||
name: Build
|
||||
run: |
|
||||
npm install
|
||||
npm run build
|
||||
uses: actions/checkout@v2
|
||||
with:
|
||||
fetch-depth: 0
|
||||
-
|
||||
name: Install
|
||||
run: npm ci
|
||||
-
|
||||
name: Build
|
||||
run: npm run build
|
||||
run: yarn install
|
||||
-
|
||||
name: Test
|
||||
run: npm run test
|
||||
run: yarn run test
|
||||
-
|
||||
name: Upload coverage
|
||||
uses: codecov/codecov-action@v1.0.7
|
||||
if: success()
|
||||
with:
|
||||
token: ${{ secrets.CODECOV_TOKEN }}
|
||||
file: ./coverage/clover.xml
|
||||
|
||||
@@ -0,0 +1,40 @@
|
||||
env:
|
||||
- GO111MODULE=on
|
||||
- GOPROXY=https://goproxy.io
|
||||
|
||||
before:
|
||||
hooks:
|
||||
- go mod download
|
||||
|
||||
builds:
|
||||
-
|
||||
env:
|
||||
- CGO_ENABLED=0
|
||||
goos:
|
||||
- darwin
|
||||
- linux
|
||||
- windows
|
||||
goarch:
|
||||
- 386
|
||||
- amd64
|
||||
|
||||
archives:
|
||||
-
|
||||
replacements:
|
||||
386: i386
|
||||
amd64: x86_64
|
||||
format_overrides:
|
||||
- goos: windows
|
||||
format: zip
|
||||
files:
|
||||
- LICENSE
|
||||
- README.md
|
||||
- CHANGELOG.md
|
||||
|
||||
checksum:
|
||||
name_template: 'checksums.txt'
|
||||
|
||||
signs:
|
||||
-
|
||||
artifacts: checksum
|
||||
args: ["--batch", "-u", "{{ .Env.GPG_FINGERPRINT }}", "--output", "${signature}", "--detach-sign", "${artifact}"]
|
||||
@@ -0,0 +1,35 @@
|
||||
env:
|
||||
- GO111MODULE=on
|
||||
- GOPROXY=https://goproxy.io
|
||||
|
||||
before:
|
||||
hooks:
|
||||
- go mod download
|
||||
|
||||
builds:
|
||||
-
|
||||
env:
|
||||
- CGO_ENABLED=0
|
||||
goos:
|
||||
- darwin
|
||||
- linux
|
||||
- windows
|
||||
goarch:
|
||||
- 386
|
||||
- amd64
|
||||
|
||||
archives:
|
||||
-
|
||||
replacements:
|
||||
386: i386
|
||||
amd64: x86_64
|
||||
format_overrides:
|
||||
- goos: windows
|
||||
format: zip
|
||||
files:
|
||||
- LICENSE
|
||||
- README.md
|
||||
- CHANGELOG.md
|
||||
|
||||
checksum:
|
||||
name_template: 'checksums.txt'
|
||||
@@ -0,0 +1,15 @@
|
||||
version = 1
|
||||
|
||||
[merge]
|
||||
automerge_label = "automerge"
|
||||
blacklist_title_regex = "^WIP.*"
|
||||
method = "squash"
|
||||
delete_branch_on_merge = true
|
||||
block_on_reviews_requested = false
|
||||
notify_on_conflict = true
|
||||
optimistic_updates = true
|
||||
|
||||
[merge.message]
|
||||
title = "pull_request_title"
|
||||
include_pr_number = true
|
||||
body_type = "markdown"
|
||||
@@ -0,0 +1,96 @@
|
||||
# Changelog
|
||||
|
||||
## 2.1.0 (2020/06/15)
|
||||
|
||||
* Implement (optional) semver parsing of version (#213)
|
||||
* Remove unshallow step (goreleaser/goreleaser#1608)
|
||||
|
||||
## 2.0.2 (2020/05/10)
|
||||
|
||||
* Use template in `sign.args`
|
||||
|
||||
## 2.0.1 (2020/05/10)
|
||||
|
||||
* Dummy release to mark v2 as latest on the marketplace
|
||||
|
||||
## 2.0.0 (2020/05/10)
|
||||
|
||||
* Remove `key` input and use [Import GPG](https://github.com/crazy-max/ghaction-import-gpg) GitHub Action instead.
|
||||
* Make `args` input as required
|
||||
* Go 1.14
|
||||
* Update deps
|
||||
|
||||
## 1.5.1 (2020/05/10)
|
||||
|
||||
* Mark `key` input as deprecated
|
||||
|
||||
## 1.5.0 (2020/05/07)
|
||||
|
||||
* Use native GitHub Action tools to download assets and use GitHub API
|
||||
* Fix unexpected output when tag not found
|
||||
* Use GitHub Action exec
|
||||
* Cleanup local paths from extra fields
|
||||
* Add notes about limitation with GITHUB_TOKEN (#58)
|
||||
* Add Codecov
|
||||
|
||||
## 1.4.0 (2020/04/09)
|
||||
|
||||
* Use ncc and clean workflows
|
||||
* Update deps
|
||||
|
||||
## 1.3.1 (2020/02/14)
|
||||
|
||||
* Don't fail on `getTag` (#98)
|
||||
|
||||
## 1.3.0 (2020/02/11)
|
||||
|
||||
* Improve git tag detection (#77)
|
||||
* Only handle snapshot flag for release cmd (#94)
|
||||
* Use `core.info` instead of `console.log`
|
||||
* Update deps
|
||||
* Update gitattributes
|
||||
|
||||
## 1.2.1 (2020/01/20)
|
||||
|
||||
* Update deps
|
||||
|
||||
## 1.2.0 (2019/12/24)
|
||||
|
||||
* Update deps
|
||||
|
||||
## 1.1.0 (2019/12/02)
|
||||
|
||||
* Add input to run GoReleaser from a subdirectory (#45)
|
||||
|
||||
## 1.0.2 (2019/11/14)
|
||||
|
||||
* Fix tsc gen
|
||||
|
||||
## 1.0.1 (2019/11/14)
|
||||
|
||||
* Update deps
|
||||
|
||||
## 1.0.0 (2019/10/04)
|
||||
|
||||
* Stable release
|
||||
* Update deps
|
||||
|
||||
## 0.4.0 (2019/09/28)
|
||||
|
||||
* Move repository to GoReleaser org (#3)
|
||||
|
||||
## 0.3.0 (2019/09/26)
|
||||
|
||||
* Artifact signing (#2)
|
||||
|
||||
## 0.2.1 (2019/09/22)
|
||||
|
||||
* Typo
|
||||
|
||||
## 0.2.0 (2019/09/20)
|
||||
|
||||
* Snapshot forced if no tag found
|
||||
|
||||
## 0.1.0 (2019/09/20)
|
||||
|
||||
* Initial version
|
||||
@@ -1,6 +1,6 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2019 CrazyMax
|
||||
Copyright (c) 2019-2020 CrazyMax
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
|
||||
@@ -5,17 +5,29 @@
|
||||
<p align="center">
|
||||
<a href="https://github.com/goreleaser/goreleaser-action/releases/latest"><img alt="GitHub release" src="https://img.shields.io/github/release/goreleaser/goreleaser-action.svg?logo=github&style=flat-square"></a>
|
||||
<a href="https://github.com/marketplace/actions/goreleaser-action"><img alt="GitHub marketplace" src="https://img.shields.io/badge/marketplace-goreleaser--action-blue?logo=github&style=flat-square"></a>
|
||||
<a href="https://github.com/goreleaser/goreleaser-action/actions?workflow=release"><img alt="Release workflow" src="https://github.com/goreleaser/goreleaser-action/workflows/release/badge.svg"></a>
|
||||
<a href="https://github.com/goreleaser/goreleaser-action/actions?workflow=test"><img alt="Test workflow" src="https://github.com/goreleaser/goreleaser-action/workflows/test/badge.svg"></a>
|
||||
<a href="https://github.com/goreleaser/goreleaser-action/actions?workflow=test"><img alt="Test workflow" src="https://img.shields.io/github/workflow/status/goreleaser/goreleaser-action/test?label=test&logo=github&style=flat-square"></a>
|
||||
<a href="https://codecov.io/gh/goreleaser/goreleaser-action"><img alt="Codecov" src="https://img.shields.io/codecov/c/github/goreleaser/goreleaser-action?logo=codecov&style=flat-square"></a>
|
||||
<a href="https://github.com/sponsors/crazy-max"><img src="https://img.shields.io/badge/sponsor-crazy--max-181717.svg?logo=github&style=flat-square" alt="Become a sponsor"></a>
|
||||
</p>
|
||||
</p>
|
||||
|
||||
---
|
||||
___
|
||||
|
||||

|
||||
|
||||
* [Usage](#usage)
|
||||
* [Workflow](#workflow)
|
||||
* [Run on new tag](#run-on-new-tag)
|
||||
* [Signing](#signing)
|
||||
* [Customizing](#customizing)
|
||||
* [inputs](#inputs)
|
||||
* [environment variables](#environment-variables)
|
||||
* [Limitation](#limitation)
|
||||
* [License](#license)
|
||||
|
||||
## Usage
|
||||
|
||||
Below is a simple snippet to use this action. A [live example](https://github.com/goreleaser/goreleaser-action/actions) is also available for this repository.
|
||||
### Workflow
|
||||
|
||||
```yaml
|
||||
name: goreleaser
|
||||
@@ -31,26 +43,26 @@ jobs:
|
||||
-
|
||||
name: Checkout
|
||||
uses: actions/checkout@v2
|
||||
-
|
||||
name: Unshallow
|
||||
run: git fetch --prune --unshallow
|
||||
with:
|
||||
fetch-depth: 0
|
||||
-
|
||||
name: Set up Go
|
||||
uses: actions/setup-go@v1
|
||||
uses: actions/setup-go@v2
|
||||
with:
|
||||
go-version: 1.13.x
|
||||
go-version: 1.14
|
||||
-
|
||||
name: Run GoReleaser
|
||||
uses: goreleaser/goreleaser-action@v1
|
||||
uses: goreleaser/goreleaser-action@v2
|
||||
with:
|
||||
version: latest
|
||||
args: release --rm-dist
|
||||
key: ${{ secrets.YOUR_PRIVATE_KEY }}
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
```
|
||||
|
||||
> **IMPORTANT**: note the `Unshallow` step. It is required for the changelog to work correctly.
|
||||
> **IMPORTANT**: note the `fetch-depth: 0` input in `Checkout` step. It is required for the changelog to work correctly.
|
||||
|
||||
### Run on new tag
|
||||
|
||||
If you want to run GoReleaser only on new tag, you can use this event:
|
||||
|
||||
@@ -66,43 +78,89 @@ Or with a condition on GoReleaser step:
|
||||
```yaml
|
||||
-
|
||||
name: Run GoReleaser
|
||||
uses: goreleaser/goreleaser-action@v1
|
||||
uses: goreleaser/goreleaser-action@v2
|
||||
if: startsWith(github.ref, 'refs/tags/')
|
||||
with:
|
||||
version: latest
|
||||
args: release --rm-dist
|
||||
key: ${{ secrets.YOUR_PRIVATE_KEY }}
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
```
|
||||
|
||||
> For detailed instructions please follow GitHub Actions [workflow syntax](https://help.github.com/en/articles/workflow-syntax-for-github-actions#About-yaml-syntax-for-workflows).
|
||||
|
||||
## Customizing
|
||||
|
||||
### Inputs
|
||||
|
||||
Following inputs can be used as `step.with` keys
|
||||
|
||||
| Name | Type | Default | Description |
|
||||
|---------------|---------|-----------|-------------------------------------------|
|
||||
| `version` | String | `latest` | GoReleaser version. Example: `v0.117.0` |
|
||||
| `args` | String | | Arguments to pass to GoReleaser |
|
||||
| `key` | String | | Private key to import |
|
||||
| `workdir` | String | `.` | Working directory (below repository root) |
|
||||
|
||||
### Signing
|
||||
|
||||
If signing is enabled in your GoReleaser configuration, populate the `key` input with your private key
|
||||
and reference the key in your signing configuration, e.g.
|
||||
If [signing is enabled](https://goreleaser.com/customization/#Signing) in your GoReleaser configuration, you can use the [Import GPG](https://github.com/crazy-max/ghaction-import-gpg) GitHub Action along with this one:
|
||||
|
||||
```yaml
|
||||
-
|
||||
name: Import GPG key
|
||||
id: import_gpg
|
||||
uses: crazy-max/ghaction-import-gpg@v2
|
||||
env:
|
||||
GPG_PRIVATE_KEY: ${{ secrets.GPG_PRIVATE_KEY }}
|
||||
PASSPHRASE: ${{ secrets.PASSPHRASE }}
|
||||
-
|
||||
name: Run GoReleaser
|
||||
uses: goreleaser/goreleaser-action@v2
|
||||
with:
|
||||
version: latest
|
||||
args: release --rm-dist
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
GPG_FINGERPRINT: ${{ steps.import_gpg.outputs.fingerprint }}
|
||||
```
|
||||
|
||||
And reference the fingerprint in your signing configuration using the `GPG_FINGERPRINT` environment variable:
|
||||
|
||||
```yaml
|
||||
signs:
|
||||
- artifacts: checksum
|
||||
args: ["--batch", "-u", "<key id, fingerprint, email, ...>", "--output", "${signature}", "--detach-sign", "${artifact}"]
|
||||
args: ["--batch", "-u", "{{ .Env.GPG_FINGERPRINT }}", "--output", "${signature}", "--detach-sign", "${artifact}"]
|
||||
```
|
||||
|
||||
This feature is currently only compatible when using the default `gpg` command and a private key without a passphrase.
|
||||
## Customizing
|
||||
|
||||
### inputs
|
||||
|
||||
Following inputs can be used as `step.with` keys
|
||||
|
||||
| Name | Type | Default | Description |
|
||||
|------------------|---------|-----------|-------------------------------------------|
|
||||
| `version`**¹** | String | `latest` | GoReleaser version |
|
||||
| `args` | String | | Arguments to pass to GoReleaser |
|
||||
| `workdir` | String | `.` | Working directory (below repository root) |
|
||||
|
||||
> **¹** Can be a fixed version like `v0.117.0` or a max satisfying semver one like `~> 0.132`. In this case this will return `v0.132.1`.
|
||||
|
||||
### environment variables
|
||||
|
||||
Following environment variables can be used as `step.env` keys
|
||||
|
||||
| Name | Description |
|
||||
|----------------|---------------------------------------|
|
||||
| `GITHUB_TOKEN` | [GITHUB_TOKEN](https://help.github.com/en/actions/configuring-and-managing-workflows/authenticating-with-the-github_token) as provided by `secrets` |
|
||||
|
||||
## Limitation
|
||||
|
||||
`GITHUB_TOKEN` permissions [are limited to the repository](https://help.github.com/en/actions/configuring-and-managing-workflows/authenticating-with-the-github_token#about-the-github_token-secret)
|
||||
that contains your workflow.
|
||||
|
||||
If you need to push the homebrew tap to another repository, you must therefore create a custom [Personal Access Token](https://help.github.com/articles/creating-a-personal-access-token-for-the-command-line/)
|
||||
with `repo` permissions and [add it as a secret in the repository](https://help.github.com/en/actions/automating-your-workflow-with-github-actions/creating-and-using-encrypted-secrets). If you create a
|
||||
secret named `GH_PAT`, the step will look like this:
|
||||
|
||||
```yaml
|
||||
-
|
||||
name: Run GoReleaser
|
||||
uses: goreleaser/goreleaser-action@v2
|
||||
with:
|
||||
version: latest
|
||||
args: release --rm-dist
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GH_PAT }}
|
||||
```
|
||||
|
||||
## License
|
||||
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
import * as git from '../src/git';
|
||||
|
||||
describe('git', () => {
|
||||
it('returns git tag', async () => {
|
||||
const tag: string = await git.getTag();
|
||||
expect(tag).not.toEqual('');
|
||||
});
|
||||
it('checks if tag is dirty', async () => {
|
||||
expect(await git.isTagDirty('v1.3.1')).toBe(true);
|
||||
});
|
||||
it('returns short commit', async () => {
|
||||
const commit: string = await git.getShortCommit();
|
||||
expect(commit).not.toEqual('');
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,19 @@
|
||||
import * as github from '../src/github';
|
||||
|
||||
describe('github', () => {
|
||||
it('returns latest GoReleaser GitHub release', async () => {
|
||||
const release = await github.getRelease('latest');
|
||||
expect(release).not.toBeNull();
|
||||
expect(release?.tag_name).not.toEqual('');
|
||||
});
|
||||
it('returns v0.117.0 GoReleaser GitHub release', async () => {
|
||||
const release = await github.getRelease('v0.117.0');
|
||||
expect(release).not.toBeNull();
|
||||
expect(release?.tag_name).toEqual('v0.117.0');
|
||||
});
|
||||
it('returns v0.132.1 GoReleaser GitHub release', async () => {
|
||||
const release = await github.getRelease('~> 0.132');
|
||||
expect(release).not.toBeNull();
|
||||
expect(release?.tag_name).toEqual('v0.132.1');
|
||||
});
|
||||
});
|
||||
+4
-3
@@ -8,15 +8,16 @@ branding:
|
||||
|
||||
inputs:
|
||||
version:
|
||||
description: 'GoReleaser version. Example: v0.118.0'
|
||||
description: 'GoReleaser version'
|
||||
default: 'latest'
|
||||
required: false
|
||||
args:
|
||||
description: 'Arguments to pass to GoReleaser'
|
||||
key:
|
||||
description: 'Private key to import'
|
||||
required: true
|
||||
workdir:
|
||||
description: 'Working directory (below repository root)'
|
||||
default: '.'
|
||||
required: false
|
||||
|
||||
runs:
|
||||
using: 'node12'
|
||||
|
||||
+3260
-23610
File diff suppressed because one or more lines are too long
@@ -1,3 +1,3 @@
|
||||
module github.com/goreleaser/goreleaser-action
|
||||
|
||||
go 1.12
|
||||
go 1.14
|
||||
|
||||
+7
-2
@@ -1,11 +1,16 @@
|
||||
module.exports = {
|
||||
clearMocks: true,
|
||||
moduleFileExtensions: ['js', 'ts'],
|
||||
setupFiles: [
|
||||
"dotenv/config",
|
||||
"<rootDir>/src/test_setup.ts"
|
||||
],
|
||||
testEnvironment: 'node',
|
||||
testMatch: ['**/*.test.ts'],
|
||||
testRunner: 'jest-circus/runner',
|
||||
testTimeout: 10000,
|
||||
transform: {
|
||||
'^.+\\.ts$': 'ts-jest'
|
||||
},
|
||||
verbose: true
|
||||
}
|
||||
verbose: false
|
||||
}
|
||||
|
||||
Generated
-54
@@ -1,54 +0,0 @@
|
||||
"use strict";
|
||||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
||||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
||||
return new (P || (P = Promise))(function (resolve, reject) {
|
||||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
||||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
||||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
||||
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
||||
});
|
||||
};
|
||||
var __importStar = (this && this.__importStar) || function (mod) {
|
||||
if (mod && mod.__esModule) return mod;
|
||||
var result = {};
|
||||
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
|
||||
result["default"] = mod;
|
||||
return result;
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const child_process = __importStar(require("child_process"));
|
||||
const git = (args = []) => __awaiter(void 0, void 0, void 0, function* () {
|
||||
const stdout = child_process.execSync(`git ${args.join(' ')}`, {
|
||||
encoding: 'utf8'
|
||||
});
|
||||
return stdout.trim();
|
||||
});
|
||||
function isTagDirty(currentTag) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
try {
|
||||
yield git(['describe', '--exact-match', '--tags', '--match', currentTag]);
|
||||
}
|
||||
catch (err) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
});
|
||||
}
|
||||
exports.isTagDirty = isTagDirty;
|
||||
function getTag() {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
try {
|
||||
return yield git(['describe', '--tags', '--abbrev=0']);
|
||||
}
|
||||
catch (err) {
|
||||
return '';
|
||||
}
|
||||
});
|
||||
}
|
||||
exports.getTag = getTag;
|
||||
function getShortCommit() {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
return yield git(['show', "--format='%h'", 'HEAD', '--quiet']);
|
||||
});
|
||||
}
|
||||
exports.getShortCommit = getShortCommit;
|
||||
Generated
-72
@@ -1,72 +0,0 @@
|
||||
"use strict";
|
||||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
||||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
||||
return new (P || (P = Promise))(function (resolve, reject) {
|
||||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
||||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
||||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
||||
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
||||
});
|
||||
};
|
||||
var __importStar = (this && this.__importStar) || function (mod) {
|
||||
if (mod && mod.__esModule) return mod;
|
||||
var result = {};
|
||||
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
|
||||
result["default"] = mod;
|
||||
return result;
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const core = __importStar(require("@actions/core"));
|
||||
const tc = __importStar(require("@actions/tool-cache"));
|
||||
const download = __importStar(require("download"));
|
||||
const fs = __importStar(require("fs"));
|
||||
const os = __importStar(require("os"));
|
||||
const path = __importStar(require("path"));
|
||||
const util = __importStar(require("util"));
|
||||
const restm = __importStar(require("typed-rest-client/RestClient"));
|
||||
let osPlat = os.platform();
|
||||
let osArch = os.arch();
|
||||
function getGoReleaser(version) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
const selected = yield determineVersion(version);
|
||||
if (selected) {
|
||||
version = selected;
|
||||
}
|
||||
core.info(`✅ GoReleaser version found: ${version}`);
|
||||
const tmpdir = fs.mkdtempSync(path.join(os.tmpdir(), 'goreleaser-'));
|
||||
const fileName = getFileName();
|
||||
const downloadUrl = util.format('https://github.com/goreleaser/goreleaser/releases/download/%s/%s', version, fileName);
|
||||
core.info(`⬇️ Downloading ${downloadUrl}...`);
|
||||
yield download.default(downloadUrl, tmpdir, { filename: fileName });
|
||||
core.info('📦 Extracting GoReleaser...');
|
||||
let extPath = tmpdir;
|
||||
if (osPlat == 'win32') {
|
||||
extPath = yield tc.extractZip(`${tmpdir}/${fileName}`);
|
||||
}
|
||||
else {
|
||||
extPath = yield tc.extractTar(`${tmpdir}/${fileName}`);
|
||||
}
|
||||
return path.join(extPath, osPlat == 'win32' ? 'goreleaser.exe' : 'goreleaser');
|
||||
});
|
||||
}
|
||||
exports.getGoReleaser = getGoReleaser;
|
||||
function getFileName() {
|
||||
const platform = osPlat == 'win32' ? 'Windows' : osPlat == 'darwin' ? 'Darwin' : 'Linux';
|
||||
const arch = osArch == 'x64' ? 'x86_64' : 'i386';
|
||||
const ext = osPlat == 'win32' ? 'zip' : 'tar.gz';
|
||||
return util.format('goreleaser_%s_%s.%s', platform, arch, ext);
|
||||
}
|
||||
function determineVersion(version) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
let rest = new restm.RestClient('goreleaser-action', 'https://github.com', undefined, {
|
||||
headers: {
|
||||
Accept: 'application/json'
|
||||
}
|
||||
});
|
||||
let res = yield rest.get(`/goreleaser/goreleaser/releases/${version}`);
|
||||
if (res.statusCode != 200 || res.result === null) {
|
||||
throw new Error(`Cannot find GoReleaser ${version} release (http ${res.statusCode})`);
|
||||
}
|
||||
return res.result.tag_name;
|
||||
});
|
||||
}
|
||||
Generated
-70
@@ -1,70 +0,0 @@
|
||||
"use strict";
|
||||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
||||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
||||
return new (P || (P = Promise))(function (resolve, reject) {
|
||||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
||||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
||||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
||||
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
||||
});
|
||||
};
|
||||
var __importStar = (this && this.__importStar) || function (mod) {
|
||||
if (mod && mod.__esModule) return mod;
|
||||
var result = {};
|
||||
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
|
||||
result["default"] = mod;
|
||||
return result;
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const git = __importStar(require("./git"));
|
||||
const installer = __importStar(require("./installer"));
|
||||
const core = __importStar(require("@actions/core"));
|
||||
const exec = __importStar(require("@actions/exec"));
|
||||
const fs = __importStar(require("fs"));
|
||||
function run(silent) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
try {
|
||||
const version = core.getInput('version') || 'latest';
|
||||
const args = core.getInput('args');
|
||||
const key = core.getInput('key');
|
||||
const workdir = core.getInput('workdir') || '.';
|
||||
const goreleaser = yield installer.getGoReleaser(version);
|
||||
const commit = yield git.getShortCommit();
|
||||
const tag = yield git.getTag();
|
||||
const isTagDirty = yield git.isTagDirty(tag);
|
||||
if (workdir && workdir !== '.') {
|
||||
core.info(`📂 Using ${workdir} as working directory...`);
|
||||
process.chdir(workdir);
|
||||
}
|
||||
let snapshot = '';
|
||||
if (args.split(' ').indexOf('release') > -1) {
|
||||
if (isTagDirty) {
|
||||
core.info(`⚠️ No tag found for commit ${commit}. Snapshot forced`);
|
||||
if (!args.includes('--snapshot')) {
|
||||
snapshot = ' --snapshot';
|
||||
}
|
||||
}
|
||||
else {
|
||||
core.info(`✅ ${tag} tag found for commit ${commit}`);
|
||||
}
|
||||
}
|
||||
if (key) {
|
||||
core.info('🔑 Importing signing key...');
|
||||
let path = `${process.env.HOME}/key.asc`;
|
||||
fs.writeFileSync(path, key, { mode: 0o600 });
|
||||
yield exec.exec('gpg', ['--import', path], {
|
||||
silent: silent
|
||||
});
|
||||
}
|
||||
core.info('🏃 Running GoReleaser...');
|
||||
yield exec.exec(`${goreleaser} ${args}${snapshot}`, undefined, {
|
||||
silent: silent
|
||||
});
|
||||
}
|
||||
catch (error) {
|
||||
core.setFailed(error.message);
|
||||
}
|
||||
});
|
||||
}
|
||||
exports.run = run;
|
||||
run();
|
||||
Generated
-8185
File diff suppressed because it is too large
Load Diff
+17
-21
@@ -1,17 +1,13 @@
|
||||
{
|
||||
"name": "goreleaser-action",
|
||||
"private": true,
|
||||
"description": "GitHub Action for GoReleaser, a release automation tool for Go projects",
|
||||
"main": "lib/main.js",
|
||||
"directories": {
|
||||
"lib": "lib"
|
||||
},
|
||||
"scripts": {
|
||||
"build": "tsc && ncc build",
|
||||
"test": "jest",
|
||||
"test": "jest --coverage",
|
||||
"format": "prettier --write **/*.ts",
|
||||
"format-check": "prettier --check **/*.ts",
|
||||
"pre-checkin": "npm run format && npm run build"
|
||||
"pre-checkin": "yarn run format && yarn run build"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
@@ -25,23 +21,23 @@
|
||||
"author": "CrazyMax",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@actions/core": "^1.2.3",
|
||||
"@actions/exec": "^1.0.3",
|
||||
"@actions/tool-cache": "^1.3.3",
|
||||
"download": "^8.0.0",
|
||||
"typed-rest-client": "^1.7.3"
|
||||
"@actions/core": "^1.2.4",
|
||||
"@actions/exec": "^1.0.4",
|
||||
"@actions/http-client": "^1.0.8",
|
||||
"@actions/tool-cache": "^1.5.5"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/download": "^6.2.4",
|
||||
"@types/jest": "^25.2.1",
|
||||
"@types/node": "^13.11.0",
|
||||
"@zeit/ncc": "^0.22.1",
|
||||
"jest": "^25.2.7",
|
||||
"jest-circus": "^25.2.7",
|
||||
"jest-runtime": "^25.2.7",
|
||||
"prettier": "^2.0.4",
|
||||
"ts-jest": "^25.3.1",
|
||||
"typescript": "^3.8.3",
|
||||
"@types/jest": "^26.0.0",
|
||||
"@types/node": "^14.0.13",
|
||||
"@zeit/ncc": "^0.22.3",
|
||||
"dotenv": "^8.2.0",
|
||||
"jest": "^26.0.1",
|
||||
"jest-circus": "^26.0.1",
|
||||
"jest-runtime": "^26.0.1",
|
||||
"prettier": "^2.0.5",
|
||||
"tmp": "^0.2.1",
|
||||
"ts-jest": "^26.1.0",
|
||||
"typescript": "^3.9.5",
|
||||
"typescript-formatter": "^7.2.2"
|
||||
}
|
||||
}
|
||||
|
||||
+34
@@ -0,0 +1,34 @@
|
||||
import * as actionsExec from '@actions/exec';
|
||||
import {ExecOptions} from '@actions/exec';
|
||||
|
||||
export interface ExecResult {
|
||||
success: boolean;
|
||||
stdout: string;
|
||||
stderr: string;
|
||||
}
|
||||
|
||||
export const exec = async (command: string, args: string[] = [], silent: boolean): Promise<ExecResult> => {
|
||||
let stdout: string = '';
|
||||
let stderr: string = '';
|
||||
|
||||
const options: ExecOptions = {
|
||||
silent: silent,
|
||||
ignoreReturnCode: true
|
||||
};
|
||||
options.listeners = {
|
||||
stdout: (data: Buffer) => {
|
||||
stdout += data.toString();
|
||||
},
|
||||
stderr: (data: Buffer) => {
|
||||
stderr += data.toString();
|
||||
}
|
||||
};
|
||||
|
||||
const returnCode: number = await actionsExec.exec(command, args, options);
|
||||
|
||||
return {
|
||||
success: returnCode === 0,
|
||||
stdout: stdout.trim(),
|
||||
stderr: stderr.trim()
|
||||
};
|
||||
};
|
||||
+15
-13
@@ -1,12 +1,22 @@
|
||||
import * as child_process from 'child_process';
|
||||
import * as exec from './exec';
|
||||
|
||||
const git = async (args: string[] = []) => {
|
||||
const stdout = child_process.execSync(`git ${args.join(' ')}`, {
|
||||
encoding: 'utf8'
|
||||
const git = async (args: string[] = []): Promise<string> => {
|
||||
return await exec.exec(`git`, args, true).then(res => {
|
||||
if (res.stderr != '' && !res.success) {
|
||||
throw new Error(res.stderr);
|
||||
}
|
||||
return res.stdout.trim();
|
||||
});
|
||||
return stdout.trim();
|
||||
};
|
||||
|
||||
export async function getTag(): Promise<string> {
|
||||
try {
|
||||
return await git(['describe', '--tags', '--abbrev=0']);
|
||||
} catch (err) {
|
||||
return '';
|
||||
}
|
||||
}
|
||||
|
||||
export async function isTagDirty(currentTag: string): Promise<boolean> {
|
||||
try {
|
||||
await git(['describe', '--exact-match', '--tags', '--match', currentTag]);
|
||||
@@ -16,14 +26,6 @@ export async function isTagDirty(currentTag: string): Promise<boolean> {
|
||||
return false;
|
||||
}
|
||||
|
||||
export async function getTag(): Promise<string> {
|
||||
try {
|
||||
return await git(['describe', '--tags', '--abbrev=0']);
|
||||
} catch (err) {
|
||||
return '';
|
||||
}
|
||||
}
|
||||
|
||||
export async function getShortCommit(): Promise<string> {
|
||||
return await git(['show', "--format='%h'", 'HEAD', '--quiet']);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,43 @@
|
||||
import * as httpm from '@actions/http-client';
|
||||
import * as core from '@actions/core';
|
||||
import * as semver from 'semver';
|
||||
|
||||
export interface GitHubRelease {
|
||||
id: number;
|
||||
tag_name: string;
|
||||
}
|
||||
|
||||
export const getRelease = async (version: string): Promise<GitHubRelease | null> => {
|
||||
const resolvedVersion: string = (await resolveVersion(version)) || version;
|
||||
const url: string = `https://github.com/goreleaser/goreleaser/releases/${resolvedVersion}`;
|
||||
const http: httpm.HttpClient = new httpm.HttpClient('goreleaser-action');
|
||||
return (await http.getJson<GitHubRelease>(url)).result;
|
||||
};
|
||||
|
||||
const resolveVersion = async (version: string): Promise<string | null> => {
|
||||
const allTags: Array<string> | null = await getAllTags();
|
||||
if (!allTags) {
|
||||
throw new Error(`Cannot find GoReleaser tags`);
|
||||
}
|
||||
core.debug(`Found ${allTags.length} tags in total`);
|
||||
|
||||
return semver.maxSatisfying(allTags, version);
|
||||
};
|
||||
|
||||
interface GitHubTag {
|
||||
tag_name: string;
|
||||
}
|
||||
|
||||
const getAllTags = async (): Promise<Array<string>> => {
|
||||
const http: httpm.HttpClient = new httpm.HttpClient('goreleaser-action');
|
||||
const url: string = `https://goreleaser.com/static/releases.json`;
|
||||
const getTags = http.getJson<Array<GitHubTag>>(url);
|
||||
|
||||
return getTags.then(response => {
|
||||
if (response.result == null) {
|
||||
return [];
|
||||
}
|
||||
|
||||
return response.result.map(obj => obj.tag_name);
|
||||
});
|
||||
};
|
||||
+27
-43
@@ -1,68 +1,52 @@
|
||||
import * as core from '@actions/core';
|
||||
import * as tc from '@actions/tool-cache';
|
||||
import * as download from 'download';
|
||||
import * as fs from 'fs';
|
||||
import * as os from 'os';
|
||||
import * as path from 'path';
|
||||
import * as util from 'util';
|
||||
import * as restm from 'typed-rest-client/RestClient';
|
||||
import * as github from './github';
|
||||
import * as core from '@actions/core';
|
||||
import * as tc from '@actions/tool-cache';
|
||||
|
||||
let osPlat: string = os.platform();
|
||||
let osArch: string = os.arch();
|
||||
const osPlat: string = os.platform();
|
||||
const osArch: string = os.arch();
|
||||
|
||||
export async function getGoReleaser(version: string): Promise<string> {
|
||||
const selected = await determineVersion(version);
|
||||
if (selected) {
|
||||
version = selected;
|
||||
const release: github.GitHubRelease | null = await github.getRelease(version);
|
||||
if (!release) {
|
||||
throw new Error(`Cannot find GoReleaser ${version} release`);
|
||||
}
|
||||
|
||||
core.info(`✅ GoReleaser version found: ${version}`);
|
||||
const tmpdir = fs.mkdtempSync(path.join(os.tmpdir(), 'goreleaser-'));
|
||||
const fileName = getFileName();
|
||||
core.info(`✅ GoReleaser version found: ${release.tag_name}`);
|
||||
const filename = getFilename();
|
||||
const downloadUrl = util.format(
|
||||
'https://github.com/goreleaser/goreleaser/releases/download/%s/%s',
|
||||
version,
|
||||
fileName
|
||||
release.tag_name,
|
||||
filename
|
||||
);
|
||||
|
||||
core.info(`⬇️ Downloading ${downloadUrl}...`);
|
||||
await download.default(downloadUrl, tmpdir, {filename: fileName});
|
||||
const downloadPath: string = await tc.downloadTool(downloadUrl);
|
||||
core.debug(`Downloaded to ${downloadPath}`);
|
||||
|
||||
core.info('📦 Extracting GoReleaser...');
|
||||
let extPath: string = tmpdir;
|
||||
let extPath: string;
|
||||
if (osPlat == 'win32') {
|
||||
extPath = await tc.extractZip(`${tmpdir}/${fileName}`);
|
||||
extPath = await tc.extractZip(downloadPath);
|
||||
} else {
|
||||
extPath = await tc.extractTar(`${tmpdir}/${fileName}`);
|
||||
extPath = await tc.extractTar(downloadPath);
|
||||
}
|
||||
core.debug(`Extracted to ${extPath}`);
|
||||
|
||||
return path.join(extPath, osPlat == 'win32' ? 'goreleaser.exe' : 'goreleaser');
|
||||
const cachePath: string = await tc.cacheDir(extPath, 'goreleaser-action', release.tag_name.replace(/^v/, ''));
|
||||
core.debug(`Cached to ${cachePath}`);
|
||||
|
||||
const exePath: string = path.join(cachePath, osPlat == 'win32' ? 'goreleaser.exe' : 'goreleaser');
|
||||
core.debug(`Exe path is ${exePath}`);
|
||||
|
||||
return exePath;
|
||||
}
|
||||
|
||||
function getFileName(): string {
|
||||
const getFilename = (): string => {
|
||||
const platform: string = osPlat == 'win32' ? 'Windows' : osPlat == 'darwin' ? 'Darwin' : 'Linux';
|
||||
const arch: string = osArch == 'x64' ? 'x86_64' : 'i386';
|
||||
const ext: string = osPlat == 'win32' ? 'zip' : 'tar.gz';
|
||||
return util.format('goreleaser_%s_%s.%s', platform, arch, ext);
|
||||
}
|
||||
|
||||
interface GitHubRelease {
|
||||
tag_name: string;
|
||||
}
|
||||
|
||||
async function determineVersion(version: string): Promise<string> {
|
||||
let rest: restm.RestClient = new restm.RestClient('goreleaser-action', 'https://github.com', undefined, {
|
||||
headers: {
|
||||
Accept: 'application/json'
|
||||
}
|
||||
});
|
||||
|
||||
let res: restm.IRestResponse<GitHubRelease> = await rest.get<GitHubRelease>(
|
||||
`/goreleaser/goreleaser/releases/${version}`
|
||||
);
|
||||
if (res.statusCode != 200 || res.result === null) {
|
||||
throw new Error(`Cannot find GoReleaser ${version} release (http ${res.statusCode})`);
|
||||
}
|
||||
|
||||
return res.result.tag_name;
|
||||
}
|
||||
};
|
||||
|
||||
+3
-16
@@ -2,13 +2,11 @@ import * as git from './git';
|
||||
import * as installer from './installer';
|
||||
import * as core from '@actions/core';
|
||||
import * as exec from '@actions/exec';
|
||||
import * as fs from 'fs';
|
||||
|
||||
export async function run(silent?: boolean) {
|
||||
async function run(): Promise<void> {
|
||||
try {
|
||||
const version = core.getInput('version') || 'latest';
|
||||
const args = core.getInput('args');
|
||||
const key = core.getInput('key');
|
||||
const args = core.getInput('args', {required: true});
|
||||
const workdir = core.getInput('workdir') || '.';
|
||||
const goreleaser = await installer.getGoReleaser(version);
|
||||
|
||||
@@ -33,19 +31,8 @@ export async function run(silent?: boolean) {
|
||||
}
|
||||
}
|
||||
|
||||
if (key) {
|
||||
core.info('🔑 Importing signing key...');
|
||||
let path = `${process.env.HOME}/key.asc`;
|
||||
fs.writeFileSync(path, key, {mode: 0o600});
|
||||
await exec.exec('gpg', ['--import', path], {
|
||||
silent: silent
|
||||
});
|
||||
}
|
||||
|
||||
core.info('🏃 Running GoReleaser...');
|
||||
await exec.exec(`${goreleaser} ${args}${snapshot}`, undefined, {
|
||||
silent: silent
|
||||
});
|
||||
await exec.exec(`${goreleaser} ${args}${snapshot}`);
|
||||
} catch (error) {
|
||||
core.setFailed(error.message);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
import tmp = require('tmp');
|
||||
|
||||
tmp.setGracefulCleanup();
|
||||
const tmpdir = tmp.dirSync({template: 'goreleaser-XXXXXX'});
|
||||
process.env = Object.assign(process.env, {
|
||||
RUNNER_TEMP: tmpdir.name,
|
||||
RUNNER_TOOL_CACHE: tmpdir.name,
|
||||
GITHUB_ACTION: '1'
|
||||
});
|
||||
+2
-1
@@ -10,7 +10,8 @@
|
||||
"rootDir": "./src",
|
||||
"strict": true,
|
||||
"noImplicitAny": false,
|
||||
"esModuleInterop": true
|
||||
"esModuleInterop": true,
|
||||
"sourceMap": true
|
||||
},
|
||||
"exclude": ["node_modules", "**/*.test.ts"]
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user