update dependencies #373
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Test, Lint | |
on: | |
push: | |
branches: | |
- "*" | |
tags: | |
- "v*" | |
pull_request: | |
env: | |
GO_VERSION: "1.21" | |
jobs: | |
test: | |
name: Run tests | |
runs-on: ubuntu-latest | |
steps: | |
- name: Setup Go ${{ env.GO_VERSION }} | |
uses: actions/setup-go@v4 | |
with: | |
go-version: ${{ env.GO_VERSION }} | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Run tests | |
run: make test | |
- uses: codecov/codecov-action@v3 | |
with: | |
file: coverage.out | |
lint: | |
name: Run linter | |
runs-on: ubuntu-latest | |
steps: | |
- name: Setup Go ${{ env.GO_VERSION }} | |
uses: actions/setup-go@v4 | |
with: | |
go-version: ${{ env.GO_VERSION }} | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Run linter | |
uses: golangci/golangci-lint-action@v3 | |
with: | |
version: latest | |
skip-cache: true | |
trigger-release: | |
name: Trigger release workflow | |
needs: [test, lint] | |
runs-on: ubuntu-latest | |
if: github.event_name != 'pull_request' | |
steps: | |
- name: Trigger release workflow | |
uses: actions/github-script@v6 | |
with: | |
# need different token, RELEASE_TOKEN belongs to digineobot | |
github-token: ${{ secrets.RELEASE_TOKEN }} | |
script: | | |
const trigger = (ref, type) => github.rest.actions.createWorkflowDispatch({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
workflow_id: 'release.yml', | |
ref, | |
inputs: { | |
goreleaser: type === 'release' ? 'true' : 'false', | |
releaseType: type, | |
} | |
}) | |
// 'refs/heads/master' or 'refs/tags/...' | |
const [_refs, kind, ref, _rest] = context.ref.split('/', 4) | |
if (kind === 'heads') { | |
await trigger(ref, "dev") | |
console.log(`triggered dev-release for ${ref}`) | |
return | |
} | |
if (kind === 'tags' && ref.startsWith('v')) { | |
await trigger(ref, "release") | |
console.log(`triggered release for ${ref}`) | |
return | |
} | |
console.warn(`unexpected git ref: ${context.ref} - skipping`) |