mirror of
https://github.com/rsteube/carapace-bin.git
synced 2025-05-05 15:32:53 +00:00
112 lines
3.1 KiB
YAML
112 lines
3.1 KiB
YAML
name: Go
|
|
|
|
on:
|
|
pull_request:
|
|
push:
|
|
|
|
jobs:
|
|
|
|
build:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: shallow clone
|
|
uses: actions/checkout@v4
|
|
if: "!startsWith(github.ref, 'refs/tags/')"
|
|
|
|
- name: deep clone
|
|
uses: actions/checkout@v4
|
|
if: startsWith(github.ref, 'refs/tags/')
|
|
with:
|
|
fetch-depth: 0
|
|
|
|
- name: Set up Go
|
|
uses: actions/setup-go@v4
|
|
with:
|
|
go-version: '1.21'
|
|
|
|
- name: Generate
|
|
run: go generate ./cmd/...
|
|
|
|
- name: Build
|
|
run: ls cmd/ | xargs -I'{}' sh -c "cd ./cmd/{} && go build -v ."
|
|
|
|
- uses: actions/upload-artifact@v4
|
|
with:
|
|
name: carapace
|
|
path: ./cmd/carapace/carapace
|
|
retention-days: 1
|
|
|
|
- name: Test
|
|
run: go test -v ./cmd/...
|
|
|
|
- name: "Check formatting"
|
|
run: '[ "$(gofmt -d -s . | tee -a /dev/stderr)" = "" ]'
|
|
|
|
- name: "staticcheck"
|
|
run: go install honnef.co/go/tools/cmd/staticcheck@latest && staticcheck ./...
|
|
|
|
- name: "carapace-lint"
|
|
run: go run ./cmd/carapace-lint completers/*/cmd/*.go
|
|
|
|
- name: Run GoReleaser
|
|
uses: goreleaser/goreleaser-action@v4
|
|
if: startsWith(github.ref, 'refs/tags/')
|
|
with:
|
|
version: latest
|
|
args: release --clean
|
|
env:
|
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
AUR_KEY: ${{ secrets.AUR_KEY }}
|
|
FURY_TOKEN: ${{ secrets.FURY_TOKEN }}
|
|
GORELEASER_GITHUB_TOKEN: ${{ secrets.GORELEASER_GITHUB_TOKEN }}
|
|
|
|
doc:
|
|
runs-on: ubuntu-latest
|
|
container: ghcr.io/carapace-sh/carapace
|
|
needs: build
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
|
|
- uses: actions/download-artifact@v4
|
|
with:
|
|
name: carapace
|
|
path: ./cmd/carapace
|
|
|
|
- name: "build docs"
|
|
run: |
|
|
chmod +x cmd/carapace/carapace
|
|
sed -i 's/\[output.linkcheck\]/#[output.linkcheck]/' docs/book.toml
|
|
sh .github/completers.sh > docs/src/completers.md
|
|
sh .github/conditions.sh > docs/src/variable/conditions.md
|
|
sh .github/macros.sh > docs/src/spec/macros.md
|
|
mdbook build docs
|
|
sh .github/badge.sh > docs/book/badge.svg
|
|
sh .github/macros-badge.sh > docs/book/macros-badge.svg
|
|
|
|
- name: "push gh-pages"
|
|
if: github.ref == 'refs/heads/master'
|
|
run: |
|
|
cd docs/book/
|
|
git init
|
|
git config user.name rsteube
|
|
git config user.email rsteube@users.noreply.github.com
|
|
git add .
|
|
git commit -m "initial commit [ci skip]"
|
|
git push --force https://rsteube:${GITHUB_TOKEN}@github.com/carapace-sh/carapace-bin.git master:gh-pages
|
|
env:
|
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
|
|
|
|
winget:
|
|
if: startsWith(github.ref, 'refs/tags/')
|
|
runs-on: ubuntu-latest
|
|
needs: build
|
|
steps:
|
|
- uses: vedantmgoyal2009/winget-releaser@v2
|
|
with:
|
|
identifier: rsteube.Carapace
|
|
max-versions-to-keep: 5
|
|
installers-regex: '_windows_amd64\.zip$'
|
|
fork-user: rsteube-bot
|
|
token: ${{ secrets.WINGET_TOKEN }}
|