2020-05-10 16:57:11 -03:00
|
|
|
# Semaphore
|
|
|
|
|
2022-04-20 00:34:24 +02:00
|
|
|
In [Semaphore 2.0](https://semaphoreci.com) each project starts with the
|
2020-05-10 16:57:11 -03:00
|
|
|
default pipeline specified in `.semaphore/semaphore.yml`.
|
|
|
|
|
2020-05-10 18:59:21 -03:00
|
|
|
```yaml
|
2020-05-10 16:57:11 -03:00
|
|
|
# .semaphore/semaphore.yml.
|
|
|
|
version: v1.0
|
|
|
|
name: Build
|
|
|
|
agent:
|
|
|
|
machine:
|
|
|
|
type: e1-standard-2
|
|
|
|
os_image: ubuntu1804
|
|
|
|
|
|
|
|
blocks:
|
|
|
|
- name: "Test"
|
|
|
|
task:
|
|
|
|
prologue:
|
|
|
|
commands:
|
|
|
|
# set go version
|
|
|
|
- sem-version go 1.11
|
|
|
|
- "export GOPATH=~/go"
|
|
|
|
- "export PATH=/home/semaphore/go/bin:$PATH"
|
|
|
|
- checkout
|
|
|
|
|
|
|
|
jobs:
|
|
|
|
- name: "Lint"
|
|
|
|
commands:
|
|
|
|
- go get ./...
|
|
|
|
- go test ./...
|
|
|
|
|
|
|
|
# On Semaphore 2.0 deployment and delivery is managed with promotions,
|
|
|
|
# which may be automatic or manual and optionally depend on conditions.
|
|
|
|
promotions:
|
|
|
|
- name: Release
|
2021-12-23 01:52:01 +01:00
|
|
|
pipeline_file: goreleaser.yaml
|
2020-05-10 16:57:11 -03:00
|
|
|
auto_promote_on:
|
|
|
|
- result: passed
|
|
|
|
branch:
|
|
|
|
- "^refs/tags/v*"
|
|
|
|
```
|
|
|
|
|
2021-12-23 01:52:01 +01:00
|
|
|
Pipeline file in `.semaphore/goreleaser.yaml`:
|
2020-05-10 16:57:11 -03:00
|
|
|
|
2020-05-10 18:59:21 -03:00
|
|
|
```yaml
|
2020-05-10 16:57:11 -03:00
|
|
|
version: "v1.0"
|
|
|
|
name: GoReleaser
|
|
|
|
agent:
|
|
|
|
machine:
|
|
|
|
type: e1-standard-2
|
|
|
|
os_image: ubuntu1804
|
|
|
|
blocks:
|
|
|
|
- name: "Release"
|
|
|
|
task:
|
|
|
|
secrets:
|
|
|
|
- name: goreleaser
|
|
|
|
prologue:
|
|
|
|
commands:
|
|
|
|
- sem-version go 1.11
|
|
|
|
- "export GOPATH=~/go"
|
|
|
|
- "export PATH=/home/semaphore/go/bin:$PATH"
|
|
|
|
- checkout
|
|
|
|
jobs:
|
|
|
|
- name: goreleaser
|
|
|
|
commands:
|
2022-04-29 08:11:04 -03:00
|
|
|
- curl -sfL https://goreleaser.com/static/run | bash
|
2020-05-10 16:57:11 -03:00
|
|
|
```
|
|
|
|
|
|
|
|
The following YAML file, `createSecret.yml` creates a new secret item that is
|
|
|
|
called GoReleaser with one environment variable, named `GITHUB_TOKEN`:
|
|
|
|
|
2020-05-10 18:59:21 -03:00
|
|
|
```yaml
|
2020-05-10 16:57:11 -03:00
|
|
|
apiVersion: v1alpha
|
|
|
|
kind: Secret
|
|
|
|
metadata:
|
|
|
|
name: goreleaser
|
|
|
|
data:
|
|
|
|
env_vars:
|
|
|
|
- name: GITHUB_TOKEN
|
2022-06-25 16:41:58 -03:00
|
|
|
value: "your token here"
|
2020-05-10 16:57:11 -03:00
|
|
|
```
|
|
|
|
|
|
|
|
Check [Managing Secrets](https://docs.semaphoreci.com/article/51-secrets-yaml-reference)
|
|
|
|
for more detailed documentation.
|