77 lines
2.3 KiB
YAML
77 lines
2.3 KiB
YAML
on: [push, pull_request, create]
|
|
|
|
name: Test
|
|
|
|
jobs:
|
|
test:
|
|
strategy:
|
|
fail-fast: false
|
|
matrix:
|
|
go-version: [1.16.x, 1.17.x]
|
|
platform: [ubuntu-latest, macos-latest, windows-latest]
|
|
runs-on: ${{ matrix.platform }}
|
|
steps:
|
|
- name: Install Matrix Go
|
|
uses: actions/setup-go@v2
|
|
with:
|
|
go-version: ${{ matrix.go-version }}
|
|
- name: Checkout code
|
|
uses: actions/checkout@v2
|
|
- name: Test code
|
|
env:
|
|
GO111MODULE: on
|
|
run: |
|
|
go test ./pkg/...
|
|
go vet ./pkg/...
|
|
build:
|
|
runs-on: ubuntu-latest
|
|
if: github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/tags/')
|
|
steps:
|
|
- name: Install Go 1.17.2
|
|
uses: actions/setup-go@v2
|
|
with:
|
|
go-version: '1.17.2'
|
|
- name: Checkout code
|
|
uses: actions/checkout@v2
|
|
- name: Build TUSD
|
|
if: startsWith(github.ref, 'refs/tags/')
|
|
env:
|
|
GO111MODULE: on
|
|
run: ./scripts/build_all.sh
|
|
- name: Release
|
|
uses: softprops/action-gh-release@v1
|
|
if: startsWith(github.ref, 'refs/tags/')
|
|
with:
|
|
files: tusd_*.*
|
|
env:
|
|
GITHUB_TOKEN: ${{ secrets.GH_RELEASE_TOKEN }}
|
|
- name: Deploy to heroku
|
|
uses: akhileshns/heroku-deploy@v3.4.6
|
|
with:
|
|
heroku_api_key: ${{secrets.HEROKU_API_KEY}}
|
|
heroku_app_name: ${{secrets.HEROKU_APP_NAME}}
|
|
heroku_email: ${{secrets.HEROKU_USER_EMAIL}}
|
|
- uses: azure/docker-login@v1
|
|
with:
|
|
username: ${{ secrets.DOCKER_USERNAME }}
|
|
password: ${{ secrets.DOCKER_PASSWORD }}
|
|
- name: Build and push docker image
|
|
run: |
|
|
docker build -t tusproject/tusd:$GITHUB_SHA .
|
|
docker push tusproject/tusd:$GITHUB_SHA
|
|
- name: Tag docker image with release tag
|
|
if: startsWith(github.ref, 'refs/tags/')
|
|
run: |
|
|
# Extract tag name: https://stackoverflow.com/a/58178121
|
|
TAG_NAME="${GITHUB_REF#refs/*/}"
|
|
docker tag tusproject/tusd:$GITHUB_SHA tusproject/tusd:$TAG_NAME
|
|
docker push tusproject/tusd:$TAG_NAME
|
|
# Create latest tag if we have no pre-release
|
|
if [[ $TAG_NAME =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]];
|
|
then
|
|
docker tag tusproject/tusd:$GITHUB_SHA tusproject/tusd:latest
|
|
docker push tusproject/tusd:latest
|
|
fi
|
|
shell: bash
|
|
|