mirror of
https://github.com/goreleaser/goreleaser-action
synced 2026-08-29 20:38:27 +00:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6e37040623 | ||
|
|
a1f27b29e7 |
@@ -1,2 +0,0 @@
|
|||||||
/coverage
|
|
||||||
/node_modules
|
|
||||||
+2
-3
@@ -1,3 +1,2 @@
|
|||||||
github: [crazy-max, caarlos0]
|
github: crazy-max
|
||||||
open_collective: goreleaser
|
custom: https://www.paypal.me/crazyws
|
||||||
custom: ["https://goreleaser.com/pro"]
|
|
||||||
|
|||||||
@@ -1,20 +0,0 @@
|
|||||||
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.
|
Before Width: | Height: | Size: 12 KiB After Width: | Height: | Size: 16 KiB |
@@ -0,0 +1,51 @@
|
|||||||
|
name: ci
|
||||||
|
|
||||||
|
on:
|
||||||
|
pull_request:
|
||||||
|
branches:
|
||||||
|
- master
|
||||||
|
- feature/*
|
||||||
|
- releases/*
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- master
|
||||||
|
- feature/*
|
||||||
|
- 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@v2
|
||||||
|
with:
|
||||||
|
go-version: 1.13
|
||||||
|
-
|
||||||
|
name: Check
|
||||||
|
uses: ./
|
||||||
|
with:
|
||||||
|
version: ${{ matrix.version }}
|
||||||
|
args: check --debug
|
||||||
|
-
|
||||||
|
name: GoReleaser
|
||||||
|
uses: ./
|
||||||
|
with:
|
||||||
|
version: ${{ matrix.version }}
|
||||||
|
args: release --skip-publish --rm-dist
|
||||||
@@ -1,198 +0,0 @@
|
|||||||
name: ci
|
|
||||||
|
|
||||||
on:
|
|
||||||
schedule:
|
|
||||||
- cron: '0 10 * * *' # everyday at 10am
|
|
||||||
push:
|
|
||||||
branches:
|
|
||||||
- 'master'
|
|
||||||
- 'releases/v*'
|
|
||||||
tags:
|
|
||||||
- 'v*'
|
|
||||||
pull_request:
|
|
||||||
branches:
|
|
||||||
- 'master'
|
|
||||||
- 'releases/v*'
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
ci:
|
|
||||||
runs-on: ${{ matrix.os }}
|
|
||||||
strategy:
|
|
||||||
fail-fast: false
|
|
||||||
matrix:
|
|
||||||
os:
|
|
||||||
- ubuntu-latest
|
|
||||||
- macOS-latest
|
|
||||||
- windows-latest
|
|
||||||
version:
|
|
||||||
- latest
|
|
||||||
- '~> 0.182'
|
|
||||||
distribution:
|
|
||||||
- goreleaser
|
|
||||||
- goreleaser-pro
|
|
||||||
steps:
|
|
||||||
-
|
|
||||||
name: Checkout
|
|
||||||
uses: actions/checkout@v2
|
|
||||||
with:
|
|
||||||
fetch-depth: 0
|
|
||||||
-
|
|
||||||
name: Set up Go
|
|
||||||
uses: actions/setup-go@v2
|
|
||||||
with:
|
|
||||||
go-version: 1.16
|
|
||||||
-
|
|
||||||
name: Check
|
|
||||||
uses: ./
|
|
||||||
with:
|
|
||||||
version: ${{ matrix.version }}
|
|
||||||
args: check --debug
|
|
||||||
workdir: ./test
|
|
||||||
-
|
|
||||||
name: GoReleaser
|
|
||||||
if: ${{ !(github.event_name == 'pull_request' && matrix.distribution == 'goreleaser-pro') }}
|
|
||||||
uses: ./
|
|
||||||
env:
|
|
||||||
GORELEASER_KEY: ${{ secrets.GORELEASER_KEY }}
|
|
||||||
with:
|
|
||||||
distribution: ${{ matrix.distribution }}
|
|
||||||
version: ${{ matrix.version }}
|
|
||||||
args: release --skip-publish --rm-dist
|
|
||||||
workdir: ./test
|
|
||||||
|
|
||||||
install-only:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
strategy:
|
|
||||||
fail-fast: false
|
|
||||||
matrix:
|
|
||||||
version:
|
|
||||||
- latest
|
|
||||||
- '~> 0.166'
|
|
||||||
distribution:
|
|
||||||
- goreleaser
|
|
||||||
- goreleaser-pro
|
|
||||||
steps:
|
|
||||||
-
|
|
||||||
name: Checkout
|
|
||||||
uses: actions/checkout@v2
|
|
||||||
with:
|
|
||||||
fetch-depth: 0
|
|
||||||
-
|
|
||||||
name: Set up Go
|
|
||||||
uses: actions/setup-go@v2
|
|
||||||
with:
|
|
||||||
go-version: 1.16
|
|
||||||
-
|
|
||||||
name: GoReleaser
|
|
||||||
if: ${{ !(github.event_name == 'pull_request' && matrix.distribution == 'goreleaser-pro') }}
|
|
||||||
uses: ./
|
|
||||||
with:
|
|
||||||
distribution: ${{ matrix.distribution }}
|
|
||||||
version: ${{ matrix.version }}
|
|
||||||
install-only: true
|
|
||||||
-
|
|
||||||
name: Check
|
|
||||||
if: ${{ !(github.event_name == 'pull_request' && matrix.distribution == 'goreleaser-pro') }}
|
|
||||||
run: |
|
|
||||||
goreleaser check --debug
|
|
||||||
|
|
||||||
signing:
|
|
||||||
runs-on: ${{ matrix.os }}
|
|
||||||
if: github.event_name != 'pull_request'
|
|
||||||
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.16
|
|
||||||
-
|
|
||||||
name: Import GPG key
|
|
||||||
id: import_gpg
|
|
||||||
uses: crazy-max/ghaction-import-gpg@v4
|
|
||||||
with:
|
|
||||||
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
|
|
||||||
workdir: ./test
|
|
||||||
env:
|
|
||||||
GPG_FINGERPRINT: ${{ steps.import_gpg.outputs.fingerprint }}
|
|
||||||
-
|
|
||||||
name: GoReleaser
|
|
||||||
uses: ./
|
|
||||||
with:
|
|
||||||
version: latest
|
|
||||||
args: -f .goreleaser-signing.yml release --skip-publish --rm-dist
|
|
||||||
workdir: ./test
|
|
||||||
env:
|
|
||||||
GPG_FINGERPRINT: ${{ steps.import_gpg.outputs.fingerprint }}
|
|
||||||
|
|
||||||
upload-artifact:
|
|
||||||
runs-on: ubuntu-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.16
|
|
||||||
-
|
|
||||||
name: Check
|
|
||||||
uses: ./
|
|
||||||
with:
|
|
||||||
args: check --debug
|
|
||||||
workdir: ./test
|
|
||||||
-
|
|
||||||
name: GoReleaser
|
|
||||||
uses: ./
|
|
||||||
with:
|
|
||||||
args: release --skip-publish --rm-dist
|
|
||||||
workdir: ./test
|
|
||||||
-
|
|
||||||
name: Upload assets
|
|
||||||
uses: actions/upload-artifact@v2
|
|
||||||
with:
|
|
||||||
name: myapp
|
|
||||||
path: ./test/dist/*
|
|
||||||
|
|
||||||
current-tag:
|
|
||||||
runs-on: ubuntu-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.16
|
|
||||||
-
|
|
||||||
name: GoReleaser
|
|
||||||
uses: ./
|
|
||||||
with:
|
|
||||||
args: release --skip-publish --rm-dist
|
|
||||||
workdir: ./test
|
|
||||||
env:
|
|
||||||
GORELEASER_CURRENT_TAG: v1.2.3
|
|
||||||
@@ -0,0 +1,26 @@
|
|||||||
|
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@v2
|
||||||
|
-
|
||||||
|
# https://github.com/actions/setup-node
|
||||||
|
name: Set up Node
|
||||||
|
uses: actions/setup-node@v1
|
||||||
|
-
|
||||||
|
name: Setup TS
|
||||||
|
run: npm install tslint typescript -g
|
||||||
|
-
|
||||||
|
name: Lint check
|
||||||
|
run: tslint './src/*.ts'
|
||||||
+27
-17
@@ -1,36 +1,46 @@
|
|||||||
name: test
|
name: test
|
||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
|
||||||
branches:
|
|
||||||
- 'master'
|
|
||||||
- 'releases/v*'
|
|
||||||
pull_request:
|
pull_request:
|
||||||
branches:
|
branches:
|
||||||
- 'master'
|
- master
|
||||||
- 'releases/v*'
|
- feature/*
|
||||||
|
- releases/*
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- master
|
||||||
|
- feature/*
|
||||||
|
- releases/*
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
test:
|
test:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ${{ matrix.os }}
|
||||||
|
strategy:
|
||||||
|
fail-fast: false
|
||||||
|
matrix:
|
||||||
|
os:
|
||||||
|
- ubuntu-latest
|
||||||
|
- macOS-latest
|
||||||
|
- windows-latest
|
||||||
steps:
|
steps:
|
||||||
-
|
-
|
||||||
|
# https://github.com/actions/checkout
|
||||||
name: Checkout
|
name: Checkout
|
||||||
uses: actions/checkout@v2
|
uses: actions/checkout@v2
|
||||||
with:
|
|
||||||
fetch-depth: 0
|
|
||||||
-
|
-
|
||||||
name: Validate
|
name: Unshallow
|
||||||
uses: docker/bake-action@v1
|
run: git fetch --prune --unshallow
|
||||||
with:
|
-
|
||||||
targets: validate
|
name: Install
|
||||||
|
run: npm install
|
||||||
-
|
-
|
||||||
name: Test
|
name: Test
|
||||||
uses: docker/bake-action@v1
|
run: npm run test
|
||||||
with:
|
|
||||||
targets: test
|
|
||||||
-
|
-
|
||||||
|
# https://github.com/codecov/codecov-action
|
||||||
name: Upload coverage
|
name: Upload coverage
|
||||||
uses: codecov/codecov-action@v2
|
uses: codecov/codecov-action@v1
|
||||||
|
if: success()
|
||||||
with:
|
with:
|
||||||
|
token: ${{ secrets.CODECOV_TOKEN }}
|
||||||
file: ./coverage/clover.xml
|
file: ./coverage/clover.xml
|
||||||
|
|||||||
@@ -1,15 +0,0 @@
|
|||||||
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,76 @@
|
|||||||
|
# Changelog
|
||||||
|
|
||||||
|
## 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
|
MIT License
|
||||||
|
|
||||||
Copyright (c) 2019-2022 CrazyMax
|
Copyright (c) 2019-2020 CrazyMax
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
of this software and associated documentation files (the "Software"), to deal
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
|||||||
@@ -7,31 +7,16 @@
|
|||||||
<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/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=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://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://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>
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
___
|
---
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
* [Usage](#usage)
|
|
||||||
* [Workflow](#workflow)
|
|
||||||
* [Run on new tag](#run-on-new-tag)
|
|
||||||
* [Signing](#signing)
|
|
||||||
* [Upload artifacts](#upload-artifacts)
|
|
||||||
* [Install Only](#install-only)
|
|
||||||
* [Customizing](#customizing)
|
|
||||||
* [inputs](#inputs)
|
|
||||||
* [outputs](#outputs)
|
|
||||||
* [environment variables](#environment-variables)
|
|
||||||
* [Limitation](#limitation)
|
|
||||||
* [Development](#development)
|
|
||||||
* [License](#license)
|
|
||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
|
|
||||||
### Workflow
|
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
name: goreleaser
|
name: goreleaser
|
||||||
|
|
||||||
@@ -46,28 +31,26 @@ jobs:
|
|||||||
-
|
-
|
||||||
name: Checkout
|
name: Checkout
|
||||||
uses: actions/checkout@v2
|
uses: actions/checkout@v2
|
||||||
with:
|
-
|
||||||
fetch-depth: 0
|
name: Unshallow
|
||||||
|
run: git fetch --prune --unshallow
|
||||||
-
|
-
|
||||||
name: Set up Go
|
name: Set up Go
|
||||||
uses: actions/setup-go@v2
|
uses: actions/setup-go@v2
|
||||||
|
with:
|
||||||
|
go-version: 1.13
|
||||||
-
|
-
|
||||||
name: Run GoReleaser
|
name: Run GoReleaser
|
||||||
uses: goreleaser/goreleaser-action@v2
|
uses: goreleaser/goreleaser-action@v1
|
||||||
with:
|
with:
|
||||||
# either 'goreleaser' (default) or 'goreleaser-pro'
|
|
||||||
distribution: goreleaser
|
|
||||||
version: latest
|
version: latest
|
||||||
args: release --rm-dist
|
args: release --rm-dist
|
||||||
|
key: ${{ secrets.YOUR_PRIVATE_KEY }}
|
||||||
env:
|
env:
|
||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
# Your GoReleaser Pro key, if you are using the 'goreleaser-pro' distribution
|
|
||||||
# GORELEASER_KEY: ${{ secrets.GORELEASER_KEY }}
|
|
||||||
```
|
```
|
||||||
|
|
||||||
> **IMPORTANT**: note the `fetch-depth: 0` input in `Checkout` step. It is required for the changelog to work correctly.
|
> **IMPORTANT**: note the `Unshallow` 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:
|
If you want to run GoReleaser only on new tag, you can use this event:
|
||||||
|
|
||||||
@@ -83,151 +66,72 @@ Or with a condition on GoReleaser step:
|
|||||||
```yaml
|
```yaml
|
||||||
-
|
-
|
||||||
name: Run GoReleaser
|
name: Run GoReleaser
|
||||||
uses: goreleaser/goreleaser-action@v2
|
uses: goreleaser/goreleaser-action@v1
|
||||||
if: startsWith(github.ref, 'refs/tags/')
|
if: startsWith(github.ref, 'refs/tags/')
|
||||||
with:
|
with:
|
||||||
version: latest
|
version: latest
|
||||||
args: release --rm-dist
|
args: release --rm-dist
|
||||||
|
key: ${{ secrets.YOUR_PRIVATE_KEY }}
|
||||||
env:
|
env:
|
||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
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).
|
> 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).
|
||||||
|
|
||||||
### Signing
|
|
||||||
|
|
||||||
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@v4
|
|
||||||
with:
|
|
||||||
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", "{{ .Env.GPG_FINGERPRINT }}", "--output", "${signature}", "--detach-sign", "${artifact}"]
|
|
||||||
```
|
|
||||||
|
|
||||||
### Upload artifacts
|
|
||||||
|
|
||||||
For some events like pull request or schedule you might want to store the artifacts somewhere for testing
|
|
||||||
purpose. You can do that with the [actions/upload-artifact](https://github.com/actions/upload-artifact) action:
|
|
||||||
|
|
||||||
```yaml
|
|
||||||
-
|
|
||||||
name: Run GoReleaser
|
|
||||||
uses: goreleaser/goreleaser-action@v2
|
|
||||||
with:
|
|
||||||
version: latest
|
|
||||||
args: release --rm-dist
|
|
||||||
env:
|
|
||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
||||||
-
|
|
||||||
name: Upload assets
|
|
||||||
uses: actions/upload-artifact@v2
|
|
||||||
with:
|
|
||||||
name: myapp
|
|
||||||
path: dist/*
|
|
||||||
```
|
|
||||||
|
|
||||||
### Install Only
|
|
||||||
|
|
||||||
```yaml
|
|
||||||
steps:
|
|
||||||
-
|
|
||||||
name: Install GoReleaser
|
|
||||||
uses: goreleaser/goreleaser-action@v2
|
|
||||||
with:
|
|
||||||
install-only: true
|
|
||||||
-
|
|
||||||
name: Show GoReleaser version
|
|
||||||
run: goreleaser -v
|
|
||||||
```
|
|
||||||
|
|
||||||
## Customizing
|
## Customizing
|
||||||
|
|
||||||
### inputs
|
### inputs
|
||||||
|
|
||||||
Following inputs can be used as `step.with` keys
|
Following inputs can be used as `step.with` keys
|
||||||
|
|
||||||
| Name | Type | Default | Description |
|
| Name | Type | Default | Description |
|
||||||
|------------------|---------|--------------|------------------------------------------------------------------|
|
|---------------|---------|-----------|-------------------------------------------|
|
||||||
| `distribution` | String | `goreleaser` | GoReleaser distribution, either `goreleaser` or `goreleaser-pro` |
|
| `version` | String | `latest` | GoReleaser version. Example: `v0.117.0` |
|
||||||
| `version`**¹** | String | `latest` | GoReleaser version |
|
| `args` | String | | Arguments to pass to GoReleaser |
|
||||||
| `args` | String | | Arguments to pass to GoReleaser |
|
| `key` | String | | Private key to import |
|
||||||
| `workdir` | String | `.` | Working directory (below repository root) |
|
| `workdir` | String | `.` | Working directory (below repository root) |
|
||||||
| `install-only` | Bool | `false` | Just install GoReleaser |
|
|
||||||
|
|
||||||
> **¹** 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`.
|
|
||||||
|
|
||||||
### outputs
|
|
||||||
|
|
||||||
Following outputs are available
|
|
||||||
|
|
||||||
| Name | Type | Description |
|
|
||||||
|-------------------|---------|---------------------------------------|
|
|
||||||
| `artifacts` | JSON | Build result artifacts |
|
|
||||||
| `metadata` | JSON | Build result metadata |
|
|
||||||
|
|
||||||
### environment variables
|
### environment variables
|
||||||
|
|
||||||
Following environment variables can be used as `step.env` keys
|
Following environment variables can be used as `step.env` keys
|
||||||
|
|
||||||
| Name | Description |
|
| 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` |
|
| `GITHUB_TOKEN` | [GITHUB_TOKEN](https://help.github.com/en/actions/configuring-and-managing-workflows/authenticating-with-the-github_token) as provided by `secrets` |
|
||||||
| `GORELEASER_KEY` | Your [GoReleaser Pro](https://goreleaser.com/pro) License Key, in case you are using the `goreleaser-pro` distribution |
|
|
||||||
|
|
||||||
## Limitation
|
## 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)
|
`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.
|
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/)
|
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
|
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:
|
secret named `GH_PAT`, the step will look like this:
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
-
|
-
|
||||||
name: Run GoReleaser
|
name: Run GoReleaser
|
||||||
uses: goreleaser/goreleaser-action@v2
|
uses: goreleaser/goreleaser-action@v1
|
||||||
with:
|
with:
|
||||||
version: latest
|
version: latest
|
||||||
args: release --rm-dist
|
args: release --rm-dist
|
||||||
|
key: ${{ secrets.YOUR_PRIVATE_KEY }}
|
||||||
env:
|
env:
|
||||||
GITHUB_TOKEN: ${{ secrets.GH_PAT }}
|
GITHUB_TOKEN: ${{ secrets.GH_PAT }}
|
||||||
```
|
```
|
||||||
|
|
||||||
## Development
|
## 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.
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
signs:
|
||||||
|
- artifacts: checksum
|
||||||
|
args: ["--batch", "-u", "<key id, fingerprint, email, ...>", "--output", "${signature}", "--detach-sign", "${artifact}"]
|
||||||
```
|
```
|
||||||
# format code and build javascript artifacts
|
|
||||||
docker buildx bake pre-checkin
|
|
||||||
|
|
||||||
# validate all code has correctly formatted and built
|
This feature is currently only compatible when using the default `gpg` command and a private key without a passphrase.
|
||||||
docker buildx bake validate
|
|
||||||
|
|
||||||
# run tests
|
|
||||||
docker buildx bake test
|
|
||||||
```
|
|
||||||
|
|
||||||
## License
|
## License
|
||||||
|
|
||||||
|
|||||||
@@ -1,31 +0,0 @@
|
|||||||
import * as os from 'os';
|
|
||||||
import * as context from '../src/context';
|
|
||||||
|
|
||||||
describe('setOutput', () => {
|
|
||||||
beforeEach(() => {
|
|
||||||
process.stdout.write = jest.fn();
|
|
||||||
});
|
|
||||||
|
|
||||||
it('setOutput produces the correct command', () => {
|
|
||||||
context.setOutput('some output', 'some value');
|
|
||||||
assertWriteCalls([`::set-output name=some output::some value${os.EOL}`]);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('setOutput handles bools', () => {
|
|
||||||
context.setOutput('some output', false);
|
|
||||||
assertWriteCalls([`::set-output name=some output::false${os.EOL}`]);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('setOutput handles numbers', () => {
|
|
||||||
context.setOutput('some output', 1.01);
|
|
||||||
assertWriteCalls([`::set-output name=some output::1.01${os.EOL}`]);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
// Assert that process.stdout.write calls called only with the given arguments.
|
|
||||||
function assertWriteCalls(calls: string[]): void {
|
|
||||||
expect(process.stdout.write).toHaveBeenCalledTimes(calls.length);
|
|
||||||
for (let i = 0; i < calls.length; i++) {
|
|
||||||
expect(process.stdout.write).toHaveBeenNthCalledWith(i + 1, calls[i]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
+3
-16
@@ -1,30 +1,17 @@
|
|||||||
import * as git from '../src/git';
|
import * as git from '../src/git';
|
||||||
|
|
||||||
describe('git', () => {
|
describe('git', () => {
|
||||||
it('returns git tag through describe', async () => {
|
it('returns git tag', async () => {
|
||||||
process.env.GITHUB_SHA = '309312125ed7a32fcd48f3a1e24dcafe669c186a';
|
|
||||||
const tag: string = await git.getTag();
|
const tag: string = await git.getTag();
|
||||||
console.log(`tag: ${tag}`);
|
console.log(tag);
|
||||||
expect(tag).not.toEqual('');
|
expect(tag).not.toEqual('');
|
||||||
});
|
});
|
||||||
it('returns git tag through GITHUB_SHA', async () => {
|
|
||||||
process.env.GITHUB_SHA = '6389ff5bd287fd6948a7ccda8af8da4f0bbc856a';
|
|
||||||
const tag: string = await git.getTag();
|
|
||||||
console.log(`tag: ${tag}`);
|
|
||||||
expect(tag).toEqual('v2.2.1');
|
|
||||||
});
|
|
||||||
it('returns git tag through GITHUB_REF', async () => {
|
|
||||||
process.env.GITHUB_REF = 'refs/tags/v2.2.1';
|
|
||||||
const tag: string = await git.getTag();
|
|
||||||
console.log(`tag: ${tag}`);
|
|
||||||
expect(tag).toEqual('v2.2.1');
|
|
||||||
});
|
|
||||||
it('checks if tag is dirty', async () => {
|
it('checks if tag is dirty', async () => {
|
||||||
expect(await git.isTagDirty('v1.3.1')).toBe(true);
|
expect(await git.isTagDirty('v1.3.1')).toBe(true);
|
||||||
});
|
});
|
||||||
it('returns short commit', async () => {
|
it('returns short commit', async () => {
|
||||||
const commit: string = await git.getShortCommit();
|
const commit: string = await git.getShortCommit();
|
||||||
console.log(`commit: ${commit}`);
|
console.log(commit);
|
||||||
expect(commit).not.toEqual('');
|
expect(commit).not.toEqual('');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -2,33 +2,15 @@ import * as github from '../src/github';
|
|||||||
|
|
||||||
describe('github', () => {
|
describe('github', () => {
|
||||||
it('returns latest GoReleaser GitHub release', async () => {
|
it('returns latest GoReleaser GitHub release', async () => {
|
||||||
const release = await github.getRelease('goreleaser', 'latest');
|
const release = await github.getRelease('latest');
|
||||||
|
console.log(release);
|
||||||
expect(release).not.toBeNull();
|
expect(release).not.toBeNull();
|
||||||
expect(release?.tag_name).not.toEqual('');
|
expect(release?.tag_name).not.toEqual('');
|
||||||
});
|
});
|
||||||
it('returns v0.182.0 GoReleaser GitHub release', async () => {
|
it('returns v0.117.0 GoReleaser GitHub release', async () => {
|
||||||
const release = await github.getRelease('goreleaser', 'v0.182.0');
|
const release = await github.getRelease('v0.117.0');
|
||||||
|
console.log(release);
|
||||||
expect(release).not.toBeNull();
|
expect(release).not.toBeNull();
|
||||||
expect(release?.tag_name).toEqual('v0.182.0');
|
expect(release?.tag_name).toEqual('v0.117.0');
|
||||||
});
|
|
||||||
it('returns v0.182.1 GoReleaser GitHub release', async () => {
|
|
||||||
const release = await github.getRelease('goreleaser', '~> 0.182');
|
|
||||||
expect(release).not.toBeNull();
|
|
||||||
expect(release?.tag_name).toEqual('v0.182.1');
|
|
||||||
});
|
|
||||||
it('returns latest GoReleaser Pro GitHub release', async () => {
|
|
||||||
const release = await github.getRelease('goreleaser-pro', 'latest');
|
|
||||||
expect(release).not.toBeNull();
|
|
||||||
expect(release?.tag_name).not.toEqual('');
|
|
||||||
});
|
|
||||||
it('returns v0.182.0-pro GoReleaser Pro GitHub release', async () => {
|
|
||||||
const release = await github.getRelease('goreleaser-pro', 'v0.182.0-pro');
|
|
||||||
expect(release).not.toBeNull();
|
|
||||||
expect(release?.tag_name).toEqual('v0.182.0-pro');
|
|
||||||
});
|
|
||||||
it('returns v0.182.1-pro GoReleaser Pro GitHub release when using semver', async () => {
|
|
||||||
const release = await github.getRelease('goreleaser-pro', '~> 0.182');
|
|
||||||
expect(release).not.toBeNull();
|
|
||||||
expect(release?.tag_name).toEqual('v0.182.1-pro');
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,33 +0,0 @@
|
|||||||
import * as fs from 'fs';
|
|
||||||
import * as goreleaser from '../src/goreleaser';
|
|
||||||
|
|
||||||
describe('install', () => {
|
|
||||||
it('acquires v0.182.0 version of GoReleaser', async () => {
|
|
||||||
const bin = await goreleaser.install('goreleaser', 'v0.182.0');
|
|
||||||
expect(fs.existsSync(bin)).toBe(true);
|
|
||||||
}, 100000);
|
|
||||||
|
|
||||||
it('acquires latest version of GoReleaser', async () => {
|
|
||||||
const bin = await goreleaser.install('goreleaser', 'latest');
|
|
||||||
expect(fs.existsSync(bin)).toBe(true);
|
|
||||||
}, 100000);
|
|
||||||
|
|
||||||
it('acquires v0.182.0-pro version of GoReleaser Pro', async () => {
|
|
||||||
const bin = await goreleaser.install('goreleaser-pro', 'v0.182.0-pro');
|
|
||||||
expect(fs.existsSync(bin)).toBe(true);
|
|
||||||
}, 100000);
|
|
||||||
|
|
||||||
it('acquires latest version of GoReleaser Pro', async () => {
|
|
||||||
const bin = await goreleaser.install('goreleaser-pro', 'latest');
|
|
||||||
expect(fs.existsSync(bin)).toBe(true);
|
|
||||||
}, 100000);
|
|
||||||
});
|
|
||||||
|
|
||||||
describe('distribSuffix', () => {
|
|
||||||
it('suffixes pro distribution', async () => {
|
|
||||||
expect(goreleaser.distribSuffix('goreleaser-pro')).toEqual('-pro');
|
|
||||||
});
|
|
||||||
it('does not suffix oss distribution', async () => {
|
|
||||||
expect(goreleaser.distribSuffix('goreleaser')).toEqual('');
|
|
||||||
});
|
|
||||||
});
|
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
import fs = require('fs');
|
||||||
|
import * as installer from '../src/installer';
|
||||||
|
|
||||||
|
describe('installer', () => {
|
||||||
|
it('acquires v0.117.0 version of GoReleaser', async () => {
|
||||||
|
const goreleaser = await installer.getGoReleaser('v0.117.0');
|
||||||
|
console.log(goreleaser);
|
||||||
|
expect(fs.existsSync(goreleaser)).toBe(true);
|
||||||
|
}, 100000);
|
||||||
|
|
||||||
|
it('acquires latest version of GoReleaser', async () => {
|
||||||
|
const goreleaser = await installer.getGoReleaser('latest');
|
||||||
|
console.log(goreleaser);
|
||||||
|
expect(fs.existsSync(goreleaser)).toBe(true);
|
||||||
|
}, 100000);
|
||||||
|
});
|
||||||
+5
-19
@@ -1,37 +1,23 @@
|
|||||||
# https://help.github.com/en/articles/metadata-syntax-for-github-actions
|
# https://help.github.com/en/articles/metadata-syntax-for-github-actions
|
||||||
name: 'GoReleaser Action'
|
name: 'GoReleaser Action'
|
||||||
description: 'GitHub Action for GoReleaser, a release automation tool for Go projects'
|
description: 'GitHub Action for GoReleaser, a release automation tool for Go projects'
|
||||||
author: 'goreleaser'
|
author: 'crazy-max'
|
||||||
branding:
|
branding:
|
||||||
color: 'green'
|
color: 'green'
|
||||||
icon: 'package'
|
icon: 'package'
|
||||||
|
|
||||||
inputs:
|
inputs:
|
||||||
distribution:
|
|
||||||
description: 'GoReleaser Distribution (goreleaser or goreleaser-pro)'
|
|
||||||
default: 'goreleaser'
|
|
||||||
required: false
|
|
||||||
version:
|
version:
|
||||||
description: 'GoReleaser version'
|
description: 'GoReleaser version. Example: v0.118.0'
|
||||||
default: 'latest'
|
default: 'latest'
|
||||||
required: false
|
|
||||||
args:
|
args:
|
||||||
description: 'Arguments to pass to GoReleaser'
|
description: 'Arguments to pass to GoReleaser'
|
||||||
required: false
|
key:
|
||||||
|
description: 'Deprecated. Use goreleaser/goreleaser-action@v2 alongside crazy-max/ghaction-import-gpg'
|
||||||
|
deprecationMessage: 'The key input will not be supported. Use goreleaser/goreleaser-action@v2 alongside crazy-max/ghaction-import-gpg'
|
||||||
workdir:
|
workdir:
|
||||||
description: 'Working directory (below repository root)'
|
description: 'Working directory (below repository root)'
|
||||||
default: '.'
|
default: '.'
|
||||||
required: false
|
|
||||||
install-only:
|
|
||||||
description: 'Just install GoReleaser'
|
|
||||||
default: 'false'
|
|
||||||
required: false
|
|
||||||
|
|
||||||
outputs:
|
|
||||||
artifacts:
|
|
||||||
description: 'Build result artifacts'
|
|
||||||
metadata:
|
|
||||||
description: 'Build result metadata'
|
|
||||||
|
|
||||||
runs:
|
runs:
|
||||||
using: 'node12'
|
using: 'node12'
|
||||||
|
|||||||
+2666
-11456
File diff suppressed because one or more lines are too long
@@ -1,67 +0,0 @@
|
|||||||
variable "NODE_VERSION" {
|
|
||||||
default = "12"
|
|
||||||
}
|
|
||||||
|
|
||||||
target "node-version" {
|
|
||||||
args = {
|
|
||||||
NODE_VERSION = NODE_VERSION
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
group "default" {
|
|
||||||
targets = ["build"]
|
|
||||||
}
|
|
||||||
|
|
||||||
group "pre-checkin" {
|
|
||||||
targets = ["vendor-update", "format", "build"]
|
|
||||||
}
|
|
||||||
|
|
||||||
group "validate" {
|
|
||||||
targets = ["format-validate", "build-validate", "vendor-validate"]
|
|
||||||
}
|
|
||||||
|
|
||||||
target "build" {
|
|
||||||
inherits = ["node-version"]
|
|
||||||
dockerfile = "./hack/build.Dockerfile"
|
|
||||||
target = "build-update"
|
|
||||||
output = ["."]
|
|
||||||
}
|
|
||||||
|
|
||||||
target "build-validate" {
|
|
||||||
inherits = ["node-version"]
|
|
||||||
dockerfile = "./hack/build.Dockerfile"
|
|
||||||
target = "build-validate"
|
|
||||||
}
|
|
||||||
|
|
||||||
target "format" {
|
|
||||||
inherits = ["node-version"]
|
|
||||||
dockerfile = "./hack/build.Dockerfile"
|
|
||||||
target = "format-update"
|
|
||||||
output = ["."]
|
|
||||||
}
|
|
||||||
|
|
||||||
target "format-validate" {
|
|
||||||
inherits = ["node-version"]
|
|
||||||
dockerfile = "./hack/build.Dockerfile"
|
|
||||||
target = "format-validate"
|
|
||||||
}
|
|
||||||
|
|
||||||
target "vendor-update" {
|
|
||||||
inherits = ["node-version"]
|
|
||||||
dockerfile = "./hack/vendor.Dockerfile"
|
|
||||||
target = "update"
|
|
||||||
output = ["."]
|
|
||||||
}
|
|
||||||
|
|
||||||
target "vendor-validate" {
|
|
||||||
inherits = ["node-version"]
|
|
||||||
dockerfile = "./hack/vendor.Dockerfile"
|
|
||||||
target = "validate"
|
|
||||||
}
|
|
||||||
|
|
||||||
target "test" {
|
|
||||||
inherits = ["node-version"]
|
|
||||||
dockerfile = "./hack/test.Dockerfile"
|
|
||||||
target = "test-coverage"
|
|
||||||
output = ["./coverage"]
|
|
||||||
}
|
|
||||||
@@ -1,3 +1,3 @@
|
|||||||
module github.com/goreleaser/goreleaser-action
|
module github.com/goreleaser/goreleaser-action
|
||||||
|
|
||||||
go 1.15
|
go 1.12
|
||||||
@@ -1,42 +0,0 @@
|
|||||||
# syntax=docker/dockerfile:1.2
|
|
||||||
ARG NODE_VERSION
|
|
||||||
|
|
||||||
FROM node:${NODE_VERSION}-alpine AS base
|
|
||||||
RUN apk add --no-cache cpio findutils git
|
|
||||||
WORKDIR /src
|
|
||||||
|
|
||||||
FROM base AS deps
|
|
||||||
RUN --mount=type=bind,target=.,rw \
|
|
||||||
--mount=type=cache,target=/src/node_modules \
|
|
||||||
yarn install
|
|
||||||
|
|
||||||
FROM deps AS build
|
|
||||||
RUN --mount=type=bind,target=.,rw \
|
|
||||||
--mount=type=cache,target=/src/node_modules \
|
|
||||||
yarn run build && mkdir /out && cp -Rf dist /out/
|
|
||||||
|
|
||||||
FROM scratch AS build-update
|
|
||||||
COPY --from=build /out /
|
|
||||||
|
|
||||||
FROM build AS build-validate
|
|
||||||
RUN --mount=type=bind,target=.,rw \
|
|
||||||
git add -A && cp -rf /out/* .; \
|
|
||||||
if [ -n "$(git status --porcelain -- dist)" ]; then \
|
|
||||||
echo >&2 'ERROR: Build result differs. Please build first with "docker buildx bake build"'; \
|
|
||||||
git status --porcelain -- dist; \
|
|
||||||
exit 1; \
|
|
||||||
fi
|
|
||||||
|
|
||||||
FROM deps AS format
|
|
||||||
RUN --mount=type=bind,target=.,rw \
|
|
||||||
--mount=type=cache,target=/src/node_modules \
|
|
||||||
yarn run format \
|
|
||||||
&& mkdir /out && find . -name '*.ts' -not -path './node_modules/*' | cpio -pdm /out
|
|
||||||
|
|
||||||
FROM scratch AS format-update
|
|
||||||
COPY --from=format /out /
|
|
||||||
|
|
||||||
FROM deps AS format-validate
|
|
||||||
RUN --mount=type=bind,target=.,rw \
|
|
||||||
--mount=type=cache,target=/src/node_modules \
|
|
||||||
yarn run format-check \
|
|
||||||
@@ -1,21 +0,0 @@
|
|||||||
# syntax=docker/dockerfile:1.2
|
|
||||||
ARG NODE_VERSION
|
|
||||||
|
|
||||||
FROM node:${NODE_VERSION}-alpine AS base
|
|
||||||
RUN apk add --no-cache git
|
|
||||||
WORKDIR /src
|
|
||||||
|
|
||||||
FROM base AS deps
|
|
||||||
RUN --mount=type=bind,target=.,rw \
|
|
||||||
--mount=type=cache,target=/src/node_modules \
|
|
||||||
yarn install
|
|
||||||
|
|
||||||
FROM deps AS test
|
|
||||||
ENV RUNNER_TEMP=/tmp/github_runner
|
|
||||||
ENV RUNNER_TOOL_CACHE=/tmp/github_tool_cache
|
|
||||||
RUN --mount=type=bind,target=.,rw \
|
|
||||||
--mount=type=cache,target=/src/node_modules \
|
|
||||||
yarn run test --coverageDirectory=/tmp/coverage
|
|
||||||
|
|
||||||
FROM scratch AS test-coverage
|
|
||||||
COPY --from=test /tmp/coverage /
|
|
||||||
@@ -1,23 +0,0 @@
|
|||||||
# syntax=docker/dockerfile:1.2
|
|
||||||
ARG NODE_VERSION
|
|
||||||
|
|
||||||
FROM node:${NODE_VERSION}-alpine AS base
|
|
||||||
RUN apk add --no-cache git
|
|
||||||
WORKDIR /src
|
|
||||||
|
|
||||||
FROM base AS vendored
|
|
||||||
RUN --mount=type=bind,target=.,rw \
|
|
||||||
--mount=type=cache,target=/src/node_modules \
|
|
||||||
yarn install && mkdir /out && cp yarn.lock /out
|
|
||||||
|
|
||||||
FROM scratch AS update
|
|
||||||
COPY --from=vendored /out /
|
|
||||||
|
|
||||||
FROM vendored AS validate
|
|
||||||
RUN --mount=type=bind,target=.,rw \
|
|
||||||
git add -A && cp -rf /out/* .; \
|
|
||||||
if [ -n "$(git status --porcelain -- yarn.lock)" ]; then \
|
|
||||||
echo >&2 'ERROR: Vendor result differs. Please vendor your package with "docker buildx bake vendor-update"'; \
|
|
||||||
git status --porcelain -- yarn.lock; \
|
|
||||||
exit 1; \
|
|
||||||
fi
|
|
||||||
+1
-5
@@ -1,14 +1,10 @@
|
|||||||
module.exports = {
|
module.exports = {
|
||||||
clearMocks: true,
|
clearMocks: true,
|
||||||
moduleFileExtensions: ['js', 'ts'],
|
moduleFileExtensions: ['js', 'ts'],
|
||||||
setupFiles: [
|
setupFiles: ["dotenv/config"],
|
||||||
"dotenv/config",
|
|
||||||
"<rootDir>/src/test_setup.ts"
|
|
||||||
],
|
|
||||||
testEnvironment: 'node',
|
testEnvironment: 'node',
|
||||||
testMatch: ['**/*.test.ts'],
|
testMatch: ['**/*.test.ts'],
|
||||||
testRunner: 'jest-circus/runner',
|
testRunner: 'jest-circus/runner',
|
||||||
testTimeout: 30000,
|
|
||||||
transform: {
|
transform: {
|
||||||
'^.+\\.ts$': 'ts-jest'
|
'^.+\\.ts$': 'ts-jest'
|
||||||
},
|
},
|
||||||
|
|||||||
Generated
+7490
File diff suppressed because it is too large
Load Diff
+18
-19
@@ -7,7 +7,8 @@
|
|||||||
"test": "jest --coverage",
|
"test": "jest --coverage",
|
||||||
"format": "prettier --write **/*.ts",
|
"format": "prettier --write **/*.ts",
|
||||||
"format-check": "prettier --check **/*.ts",
|
"format-check": "prettier --check **/*.ts",
|
||||||
"pre-checkin": "yarn run format && yarn run build"
|
"cleanup-paths": "removeNPMAbsolutePaths ./ --force --fields _where _args",
|
||||||
|
"pre-checkin": "npm run format && npm run cleanup-paths && npm run build"
|
||||||
},
|
},
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
@@ -21,25 +22,23 @@
|
|||||||
"author": "CrazyMax",
|
"author": "CrazyMax",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@actions/core": "^1.6.0",
|
"@actions/core": "^1.2.4",
|
||||||
"@actions/exec": "^1.1.0",
|
"@actions/exec": "^1.0.4",
|
||||||
"@actions/http-client": "^1.0.11",
|
"@actions/http-client": "^1.0.8",
|
||||||
"@actions/tool-cache": "^1.7.1",
|
"@actions/tool-cache": "^1.3.4"
|
||||||
"js-yaml": "^4.1.0",
|
|
||||||
"yargs": "^17.3.1"
|
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@types/jest": "^26.0.24",
|
"@types/jest": "^25.2.1",
|
||||||
"@types/node": "^14.17.6",
|
"@types/node": "^13.13.5",
|
||||||
"@vercel/ncc": "^0.28.6",
|
"@zeit/ncc": "^0.22.1",
|
||||||
"dotenv": "^8.6.0",
|
"dotenv": "^8.2.0",
|
||||||
"jest": "^26.6.3",
|
"jest": "^25.5.4",
|
||||||
"jest-circus": "^26.6.3",
|
"jest-circus": "^26.0.1",
|
||||||
"jest-runtime": "^26.6.3",
|
"jest-runtime": "^26.0.1",
|
||||||
"prettier": "^2.3.2",
|
"prettier": "^2.0.5",
|
||||||
"tmp": "^0.2.1",
|
"removeNPMAbsolutePaths": "^2.0.0",
|
||||||
"ts-jest": "^26.5.6",
|
"ts-jest": "^25.5.0",
|
||||||
"typescript": "^4.3.5",
|
"typescript": "^3.8.3",
|
||||||
"typescript-formatter": "^7.2.2"
|
"typescript-formatter": "^7.2.2"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,29 +0,0 @@
|
|||||||
import * as os from 'os';
|
|
||||||
import * as core from '@actions/core';
|
|
||||||
import {issueCommand} from '@actions/core/lib/command';
|
|
||||||
|
|
||||||
export const osPlat: string = os.platform();
|
|
||||||
export const osArch: string = os.arch();
|
|
||||||
|
|
||||||
export interface Inputs {
|
|
||||||
distribution: string;
|
|
||||||
version: string;
|
|
||||||
args: string;
|
|
||||||
workdir: string;
|
|
||||||
installOnly: boolean;
|
|
||||||
}
|
|
||||||
|
|
||||||
export async function getInputs(): Promise<Inputs> {
|
|
||||||
return {
|
|
||||||
distribution: core.getInput('distribution') || 'goreleaser',
|
|
||||||
version: core.getInput('version'),
|
|
||||||
args: core.getInput('args'),
|
|
||||||
workdir: core.getInput('workdir') || '.',
|
|
||||||
installOnly: core.getBooleanInput('install-only')
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
// FIXME: Temp fix https://github.com/actions/toolkit/issues/777
|
|
||||||
export function setOutput(name: string, value: any): void {
|
|
||||||
issueCommand('set-output', {name}, value);
|
|
||||||
}
|
|
||||||
+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()
|
||||||
|
};
|
||||||
|
};
|
||||||
+8
-26
@@ -1,35 +1,17 @@
|
|||||||
import * as exec from '@actions/exec';
|
import * as exec from './exec';
|
||||||
|
|
||||||
const git = async (args: string[] = []): Promise<string> => {
|
const git = async (args: string[] = []): Promise<string> => {
|
||||||
return await exec
|
return await exec.exec(`git`, args, true).then(res => {
|
||||||
.getExecOutput(`git`, args, {
|
if (res.stderr != '' && !res.success) {
|
||||||
ignoreReturnCode: true,
|
throw new Error(res.stderr);
|
||||||
silent: true
|
}
|
||||||
})
|
return res.stdout.trim();
|
||||||
.then(res => {
|
});
|
||||||
if (res.stderr.length > 0 && res.exitCode != 0) {
|
|
||||||
throw new Error(res.stderr);
|
|
||||||
}
|
|
||||||
return res.stdout.trim();
|
|
||||||
});
|
|
||||||
};
|
};
|
||||||
|
|
||||||
export async function getTag(): Promise<string> {
|
export async function getTag(): Promise<string> {
|
||||||
try {
|
try {
|
||||||
if ((process.env.GITHUB_REF || '').startsWith('refs/tags')) {
|
return await git(['describe', '--tags', '--abbrev=0']);
|
||||||
const tag = (process.env.GITHUB_REF || '').split('/').pop();
|
|
||||||
if (tag !== '' && tag !== undefined) {
|
|
||||||
return tag;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return await git(['tag', '--points-at', `${process.env.GITHUB_SHA}`, '--sort', '-version:creatordate']).then(
|
|
||||||
tags => {
|
|
||||||
if (tags.length == 0) {
|
|
||||||
return git(['describe', '--tags', '--abbrev=0']);
|
|
||||||
}
|
|
||||||
return tags.split('\n')[0];
|
|
||||||
}
|
|
||||||
);
|
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-43
@@ -1,6 +1,3 @@
|
|||||||
import * as goreleaser from './goreleaser';
|
|
||||||
import * as semver from 'semver';
|
|
||||||
import * as core from '@actions/core';
|
|
||||||
import * as httpm from '@actions/http-client';
|
import * as httpm from '@actions/http-client';
|
||||||
|
|
||||||
export interface GitHubRelease {
|
export interface GitHubRelease {
|
||||||
@@ -8,46 +5,8 @@ export interface GitHubRelease {
|
|||||||
tag_name: string;
|
tag_name: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const getRelease = async (distribution: string, version: string): Promise<GitHubRelease | null> => {
|
export const getRelease = async (version: string): Promise<GitHubRelease | null> => {
|
||||||
const resolvedVersion: string = (await resolveVersion(distribution, version)) || version;
|
const url: string = `https://github.com/goreleaser/goreleaser/releases/${version}`;
|
||||||
const url: string = `https://github.com/goreleaser/${distribution}/releases/${resolvedVersion}`;
|
|
||||||
const http: httpm.HttpClient = new httpm.HttpClient('goreleaser-action');
|
const http: httpm.HttpClient = new httpm.HttpClient('goreleaser-action');
|
||||||
return (await http.getJson<GitHubRelease>(url)).result;
|
return (await http.getJson<GitHubRelease>(url)).result;
|
||||||
};
|
};
|
||||||
|
|
||||||
const resolveVersion = async (distribution: string, version: string): Promise<string | null> => {
|
|
||||||
const allTags: Array<string> | null = await getAllTags(distribution);
|
|
||||||
if (!allTags) {
|
|
||||||
throw new Error(`Cannot find GoReleaser tags`);
|
|
||||||
}
|
|
||||||
core.debug(`Found ${allTags.length} tags in total`);
|
|
||||||
|
|
||||||
if (version === 'latest' || !goreleaser.isPro(distribution)) {
|
|
||||||
return semver.maxSatisfying(allTags, version);
|
|
||||||
}
|
|
||||||
|
|
||||||
const cleanTags: Array<string> = allTags.map(tag => cleanTag(tag));
|
|
||||||
const cleanVersion: string = cleanTag(version);
|
|
||||||
return semver.maxSatisfying(cleanTags, cleanVersion) + goreleaser.distribSuffix(distribution);
|
|
||||||
};
|
|
||||||
|
|
||||||
interface GitHubTag {
|
|
||||||
tag_name: string;
|
|
||||||
}
|
|
||||||
|
|
||||||
const getAllTags = async (distribution: string): Promise<Array<string>> => {
|
|
||||||
const http: httpm.HttpClient = new httpm.HttpClient('goreleaser-action');
|
|
||||||
const suffix: string = goreleaser.distribSuffix(distribution);
|
|
||||||
const url: string = `https://goreleaser.com/static/releases${suffix}.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);
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
const cleanTag = (tag: string): string => {
|
|
||||||
return tag.replace(/-pro$/, '');
|
|
||||||
};
|
|
||||||
|
|||||||
@@ -1,111 +0,0 @@
|
|||||||
import * as fs from 'fs';
|
|
||||||
import * as path from 'path';
|
|
||||||
import * as util from 'util';
|
|
||||||
import yaml from 'js-yaml';
|
|
||||||
import * as context from './context';
|
|
||||||
import * as github from './github';
|
|
||||||
import * as core from '@actions/core';
|
|
||||||
import * as tc from '@actions/tool-cache';
|
|
||||||
|
|
||||||
export async function install(distribution: string, version: string): Promise<string> {
|
|
||||||
const release: github.GitHubRelease | null = await github.getRelease(distribution, version);
|
|
||||||
if (!release) {
|
|
||||||
throw new Error(`Cannot find GoReleaser ${version} release`);
|
|
||||||
}
|
|
||||||
|
|
||||||
const filename = getFilename(distribution);
|
|
||||||
const downloadUrl = util.format(
|
|
||||||
'https://github.com/goreleaser/%s/releases/download/%s/%s',
|
|
||||||
distribution,
|
|
||||||
release.tag_name,
|
|
||||||
filename
|
|
||||||
);
|
|
||||||
|
|
||||||
core.info(`Downloading ${downloadUrl}`);
|
|
||||||
const downloadPath: string = await tc.downloadTool(downloadUrl);
|
|
||||||
core.debug(`Downloaded to ${downloadPath}`);
|
|
||||||
|
|
||||||
core.info('Extracting GoReleaser');
|
|
||||||
let extPath: string;
|
|
||||||
if (context.osPlat == 'win32') {
|
|
||||||
extPath = await tc.extractZip(downloadPath);
|
|
||||||
} else {
|
|
||||||
extPath = await tc.extractTar(downloadPath);
|
|
||||||
}
|
|
||||||
core.debug(`Extracted to ${extPath}`);
|
|
||||||
|
|
||||||
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, context.osPlat == 'win32' ? 'goreleaser.exe' : 'goreleaser');
|
|
||||||
core.debug(`Exe path is ${exePath}`);
|
|
||||||
|
|
||||||
return exePath;
|
|
||||||
}
|
|
||||||
|
|
||||||
export const distribSuffix = (distribution: string): string => {
|
|
||||||
return isPro(distribution) ? '-pro' : '';
|
|
||||||
};
|
|
||||||
|
|
||||||
export const isPro = (distribution: string): boolean => {
|
|
||||||
return distribution === 'goreleaser-pro';
|
|
||||||
};
|
|
||||||
|
|
||||||
const getFilename = (distribution: string): string => {
|
|
||||||
let arch: string;
|
|
||||||
switch (context.osArch) {
|
|
||||||
case 'x64': {
|
|
||||||
arch = 'x86_64';
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case 'x32': {
|
|
||||||
arch = 'i386';
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case 'arm': {
|
|
||||||
const arm_version = (process.config.variables as any).arm_version;
|
|
||||||
arch = arm_version ? 'armv' + arm_version : 'arm';
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
default: {
|
|
||||||
arch = context.osArch;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (context.osPlat == 'darwin') {
|
|
||||||
arch = 'all';
|
|
||||||
}
|
|
||||||
const platform: string = context.osPlat == 'win32' ? 'Windows' : context.osPlat == 'darwin' ? 'Darwin' : 'Linux';
|
|
||||||
const ext: string = context.osPlat == 'win32' ? 'zip' : 'tar.gz';
|
|
||||||
const suffix: string = distribSuffix(distribution);
|
|
||||||
return util.format('goreleaser%s_%s_%s.%s', suffix, platform, arch, ext);
|
|
||||||
};
|
|
||||||
|
|
||||||
export async function getDistPath(yamlfile: string): Promise<string> {
|
|
||||||
const cfg = yaml.load(yamlfile);
|
|
||||||
return cfg.dist || 'dist';
|
|
||||||
}
|
|
||||||
|
|
||||||
export async function getArtifacts(distpath: string): Promise<string | undefined> {
|
|
||||||
const artifactsFile = path.join(distpath, 'artifacts.json');
|
|
||||||
if (!fs.existsSync(artifactsFile)) {
|
|
||||||
return undefined;
|
|
||||||
}
|
|
||||||
const content = fs.readFileSync(artifactsFile, {encoding: 'utf-8'}).trim();
|
|
||||||
if (content === 'null') {
|
|
||||||
return undefined;
|
|
||||||
}
|
|
||||||
return content;
|
|
||||||
}
|
|
||||||
|
|
||||||
export async function getMetadata(distpath: string): Promise<string | undefined> {
|
|
||||||
const metadataFile = path.join(distpath, 'metadata.json');
|
|
||||||
if (!fs.existsSync(metadataFile)) {
|
|
||||||
return undefined;
|
|
||||||
}
|
|
||||||
const content = fs.readFileSync(metadataFile, {encoding: 'utf-8'}).trim();
|
|
||||||
if (content === 'null') {
|
|
||||||
return undefined;
|
|
||||||
}
|
|
||||||
return content;
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,52 @@
|
|||||||
|
import * as os from 'os';
|
||||||
|
import * as path from 'path';
|
||||||
|
import * as util from 'util';
|
||||||
|
import * as github from './github';
|
||||||
|
import * as core from '@actions/core';
|
||||||
|
import * as tc from '@actions/tool-cache';
|
||||||
|
|
||||||
|
const osPlat: string = os.platform();
|
||||||
|
const osArch: string = os.arch();
|
||||||
|
|
||||||
|
export async function getGoReleaser(version: string): Promise<string> {
|
||||||
|
const release: github.GitHubRelease | null = await github.getRelease(version);
|
||||||
|
if (!release) {
|
||||||
|
throw new Error(`Cannot find GoReleaser ${version} release`);
|
||||||
|
}
|
||||||
|
|
||||||
|
core.info(`✅ GoReleaser version found: ${release.tag_name}`);
|
||||||
|
const filename = getFilename();
|
||||||
|
const downloadUrl = util.format(
|
||||||
|
'https://github.com/goreleaser/goreleaser/releases/download/%s/%s',
|
||||||
|
release.tag_name,
|
||||||
|
filename
|
||||||
|
);
|
||||||
|
|
||||||
|
core.info(`⬇️ Downloading ${downloadUrl}...`);
|
||||||
|
const downloadPath: string = await tc.downloadTool(downloadUrl);
|
||||||
|
core.debug(`Downloaded to ${downloadPath}`);
|
||||||
|
|
||||||
|
core.info('📦 Extracting GoReleaser...');
|
||||||
|
let extPath: string;
|
||||||
|
if (osPlat == 'win32') {
|
||||||
|
extPath = await tc.extractZip(downloadPath);
|
||||||
|
} else {
|
||||||
|
extPath = await tc.extractTar(downloadPath);
|
||||||
|
}
|
||||||
|
core.debug(`Extracted to ${extPath}`);
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
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);
|
||||||
|
};
|
||||||
+22
-60
@@ -1,85 +1,47 @@
|
|||||||
import * as fs from 'fs';
|
|
||||||
import * as path from 'path';
|
|
||||||
import yargs from 'yargs';
|
|
||||||
import * as context from './context';
|
|
||||||
import * as git from './git';
|
import * as git from './git';
|
||||||
import * as goreleaser from './goreleaser';
|
import * as installer from './installer';
|
||||||
import * as core from '@actions/core';
|
import * as core from '@actions/core';
|
||||||
import * as exec from '@actions/exec';
|
import * as exec from '@actions/exec';
|
||||||
|
import * as fs from 'fs';
|
||||||
|
|
||||||
async function run(): Promise<void> {
|
async function run(): Promise<void> {
|
||||||
try {
|
try {
|
||||||
const inputs: context.Inputs = await context.getInputs();
|
const version = core.getInput('version') || 'latest';
|
||||||
const bin = await goreleaser.install(inputs.distribution, inputs.version);
|
const args = core.getInput('args');
|
||||||
core.info(`GoReleaser ${inputs.version} installed successfully`);
|
const key = core.getInput('key');
|
||||||
|
const workdir = core.getInput('workdir') || '.';
|
||||||
if (inputs.installOnly) {
|
const goreleaser = await installer.getGoReleaser(version);
|
||||||
const goreleaserDir = path.dirname(bin);
|
|
||||||
core.addPath(goreleaserDir);
|
|
||||||
core.debug(`Added ${goreleaserDir} to PATH`);
|
|
||||||
return;
|
|
||||||
} else if (!inputs.args) {
|
|
||||||
core.setFailed('args input required');
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (inputs.workdir && inputs.workdir !== '.') {
|
|
||||||
core.info(`Using ${inputs.workdir} as working directory`);
|
|
||||||
process.chdir(inputs.workdir);
|
|
||||||
}
|
|
||||||
|
|
||||||
const commit = await git.getShortCommit();
|
const commit = await git.getShortCommit();
|
||||||
const tag = await git.getTag();
|
const tag = await git.getTag();
|
||||||
const isTagDirty = await git.isTagDirty(tag);
|
const isTagDirty = await git.isTagDirty(tag);
|
||||||
|
|
||||||
let yamlfile: string | unknown;
|
if (workdir && workdir !== '.') {
|
||||||
const argv = yargs.parse(inputs.args);
|
core.info(`📂 Using ${workdir} as working directory...`);
|
||||||
if (argv.config) {
|
process.chdir(workdir);
|
||||||
yamlfile = argv.config;
|
|
||||||
} else {
|
|
||||||
['.goreleaser.yaml', '.goreleaser.yml', 'goreleaser.yaml', 'goreleaser.yml'].forEach(f => {
|
|
||||||
if (fs.existsSync(f)) {
|
|
||||||
yamlfile = f;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
let snapshot = '';
|
let snapshot = '';
|
||||||
if (inputs.args.split(' ').indexOf('release') > -1) {
|
if (args.split(' ').indexOf('release') > -1) {
|
||||||
if (isTagDirty) {
|
if (isTagDirty) {
|
||||||
if (!inputs.args.includes('--snapshot') && !inputs.args.includes('--nightly')) {
|
core.info(`⚠️ No tag found for commit ${commit}. Snapshot forced`);
|
||||||
core.info(`No tag found for commit ${commit}. Snapshot forced`);
|
if (!args.includes('--snapshot')) {
|
||||||
snapshot = ' --snapshot';
|
snapshot = ' --snapshot';
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
core.info(`${tag} tag found for commit ${commit}`);
|
core.info(`✅ ${tag} tag found for commit ${commit}`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
await exec.exec(`${bin} ${inputs.args}${snapshot}`, undefined, {
|
if (key) {
|
||||||
env: Object.assign({}, process.env, {
|
core.info('🔑 Importing signing key...');
|
||||||
GORELEASER_CURRENT_TAG: process.env.GORELEASER_CURRENT_TAG || tag || ''
|
let path = `${process.env.HOME}/key.asc`;
|
||||||
}) as {
|
fs.writeFileSync(path, key, {mode: 0o600});
|
||||||
[key: string]: string;
|
await exec.exec('gpg', ['--import', path]);
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
if (typeof yamlfile === 'string') {
|
|
||||||
const artifacts = await goreleaser.getArtifacts(await goreleaser.getDistPath(yamlfile));
|
|
||||||
if (artifacts) {
|
|
||||||
await core.group(`Artifacts output`, async () => {
|
|
||||||
core.info(artifacts);
|
|
||||||
context.setOutput('artifacts', artifacts);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
const metadata = await goreleaser.getMetadata(await goreleaser.getDistPath(yamlfile));
|
|
||||||
if (metadata) {
|
|
||||||
await core.group(`Metadata output`, async () => {
|
|
||||||
core.info(metadata);
|
|
||||||
context.setOutput('metadata', metadata);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
core.info('🏃 Running GoReleaser...');
|
||||||
|
await exec.exec(`${goreleaser} ${args}${snapshot}`);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
core.setFailed(error.message);
|
core.setFailed(error.message);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,9 +0,0 @@
|
|||||||
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'
|
|
||||||
});
|
|
||||||
@@ -1,35 +0,0 @@
|
|||||||
env:
|
|
||||||
- GO111MODULE=on
|
|
||||||
|
|
||||||
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
|
|
||||||
|
|
||||||
checksum:
|
|
||||||
name_template: 'checksums.txt'
|
|
||||||
|
|
||||||
signs:
|
|
||||||
-
|
|
||||||
artifacts: checksum
|
|
||||||
args: ["--batch", "-u", "{{ .Env.GPG_FINGERPRINT }}", "--output", "${signature}", "--detach-sign", "${artifact}"]
|
|
||||||
@@ -1,30 +0,0 @@
|
|||||||
env:
|
|
||||||
- GO111MODULE=on
|
|
||||||
|
|
||||||
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
|
|
||||||
|
|
||||||
checksum:
|
|
||||||
name_template: 'checksums.txt'
|
|
||||||
+1
-2
@@ -3,8 +3,7 @@
|
|||||||
"target": "es6",
|
"target": "es6",
|
||||||
"module": "commonjs",
|
"module": "commonjs",
|
||||||
"lib": [
|
"lib": [
|
||||||
"es6",
|
"es6"
|
||||||
"dom"
|
|
||||||
],
|
],
|
||||||
"newLine": "lf",
|
"newLine": "lf",
|
||||||
"outDir": "./lib",
|
"outDir": "./lib",
|
||||||
|
|||||||
Reference in New Issue
Block a user