Skip to content

docs: add Developing Tsuru Plugins (branch: beta-v2) #673

docs: add Developing Tsuru Plugins (branch: beta-v2)

docs: add Developing Tsuru Plugins (branch: beta-v2) #673

Workflow file for this run

# Copyright © 2023 tsuru-client authors
# Use of this source code is governed by a BSD-style
# license that can be found in the LICENSE file.
name: Go
on: [push, pull_request]
env:
GO_VERSION: "1.20.2"
jobs:
test:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macOS-latest]
steps:
- uses: actions/setup-go@v4
with:
go-version: ${{ env.GO_VERSION }}
- uses: actions/checkout@v3
- uses: actions/cache@v3
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- run: make test-ci
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/setup-go@v4
with:
go-version: ${{ env.GO_VERSION }}
- uses: actions/checkout@v3
with:
fetch-depth: 0
- run: make lint
pre-commit:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- uses: pre-commit/[email protected]
coverage:
if: github.ref == 'refs/heads/main' || github.ref == 'refs/heads/beta-v2'
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/setup-go@v4
with:
go-version: ${{ env.GO_VERSION }}
- uses: actions/checkout@v3
- run: make test-coverage
- name: Generate coverage badge
run: ./scripts/coverage_badge.sh
- name: Save static files for gh-pages
run: |
mkdir -p public
cp -r coverage/ public/coverage/
- name: Publish to gh-pages
uses: peaceiris/actions-gh-pages@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./public
force_orphan: true
docker_deploy:
if: github.event_name != 'pull_request' && startsWith(github.ref, 'refs/tags/')
name: "publish image on dockerhub"
needs: [test, lint, pre-commit]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- uses: docker/setup-qemu-action@v2
- uses: docker/setup-buildx-action@v2
- uses: actions/cache@v3
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx-${{ github.sha }}
restore-keys: |
${{ runner.os }}-buildx-
- name: List docker image tags
uses: docker/metadata-action@v4
id: dockermeta
with:
images: tsuru/client
tags: |
type=match,value=latest,pattern=\d.\d.\d
type=edge
type=ref,event=branch
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}
- uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_PASSWORD }}
- name: Build and Push image to docker hub
uses: docker/build-push-action@v3
with:
file: ./Dockerfile
build-args: |
DOCKER_BUILD_TSURU_VERSION="v${{steps.dockermeta.outputs.version}}"
push: true
tags: ${{ steps.dockermeta.outputs.tags }}
labels: ${{ steps.dockermeta.outputs.labels }}
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache
platforms: linux/386,linux/amd64,linux/arm/v7,linux/arm64/v8
release:
if: github.event_name != 'pull_request' && startsWith(github.ref, 'refs/tags/')
needs: [test, lint, pre-commit]
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/setup-go@v4
with:
go-version: ${{ env.GO_VERSION }}
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v4
with:
distribution: goreleaser
version: "~> v1.18" # v1.18.2
args: release --clean
env:
# The automatic GitHub token (namely secrets.GITHUB_TOKEN) doesn't have permission cross-project.
HOMEBREW_TSURU_REPOSITORY_AUTH_TOKEN: ${{ secrets.CUSTOM_GITHUB_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
AUR_KEY: ${{ secrets.PRIVATE_SSH_KEY }}
- uses: ruby/setup-ruby@v1
with:
ruby-version: "3.0"
- name: Publish to Packagecloud
run: ./scripts/build_publish_to_packagecloud.sh
env:
PACKAGE_NAME: tsuru-client
PACKAGECLOUD_TOKEN: ${{ secrets.PACKAGECLOUD_TOKEN }}
SKIP_GORELEASER: "true"