3
0
corteza/.github/workflows/release.yml
2022-06-15 15:29:51 +02:00

127 lines
3.6 KiB
YAML

name: release
on:
push:
tags:
- '**'
jobs:
test:
runs-on: ubuntu-latest
env:
GOFLAGS: -mod=readonly
steps:
- uses: actions/checkout@v2
- uses: actions/setup-go@v1
with:
go-version: 1.18
- uses: actions/cache@v2
if: ${{ !env.ACT }}
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: ${{ runner.os }}-go-
- run: make test.all
# Building web console for server and cache it for release-* steps
# we'll do this in parallel with tests to gain a few seconds
build-web-console:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
with:
node-version: '16'
- uses: actions/cache@v2
if: ${{ !env.ACT }}
with:
path: ~/.npm
key: ${{ runner.OS }}-node-${{ hashFiles('**/yarn.lock') }}
restore-keys: ${{ runner.OS }}-node-
- name: Install dependencies
working-directory: ./webconsole
run: yarn install
- name: Build Package
working-directory: ./webconsole
run: yarn build
- name: Cache console build
uses: actions/cache@v2
with: { path: ./webconsole/dist, key: console-build }
release-linux:
runs-on: ubuntu-latest
needs: [ build-web-console, test ]
env:
BUILD_OS: linux
BUILD_ARCH: amd64
RELEASE_SFTP_KEY: ${{ secrets.RELEASE_SFTP_KEY }}
RELEASE_SFTP_URI: ${{ secrets.RELEASE_SFTP_URI }}
steps:
- run: echo "BUILD_VERSION=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV
- uses: actions/checkout@v2
- uses: actions/setup-go@v1
with:
go-version: 1.18
- name: Restore console build from cache
uses: actions/cache@v2
with: { path: ./webconsole/dist, key: console-build }
- run: make release-clean release
- run: make upload
if: ${{ !env.ACT }}
release-darwin:
runs-on: macos-latest
needs: [ build-web-console, test ]
env:
BUILD_OS: darwin
BUILD_ARCH: amd64
BUILD_VERSION: ${{ format(github.ref, 'refs/tags/', '') }}
RELEASE_SFTP_KEY: ${{ secrets.RELEASE_SFTP_KEY }}
RELEASE_SFTP_URI: ${{ secrets.RELEASE_SFTP_URI }}
steps:
- run: echo "BUILD_VERSION=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV
- uses: actions/checkout@v2
- uses: actions/setup-go@v1
with:
go-version: 1.18
- uses: actions/cache@v2
if: ${{ !env.ACT }}
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: ${{ runner.os }}-go-
- name: Restore console build from cache
uses: actions/cache@v2
with: { path: ./webconsole, key: console-build }
- run: make release-clean release
- run: make upload
if: ${{ !env.ACT }}
release-docker:
runs-on: ubuntu-latest
needs: [ release-linux ]
env:
BUILD_OS: linux
BUILD_ARCH: amd64
steps:
- run: echo "BUILD_VERSION=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV
- uses: actions/checkout@v2
- uses: docker/login-action@v1
if: ${{ !env.ACT }}
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- run: |
docker build --build-arg "VERSION=${{ env.BUILD_VERSION }}" \
-t cortezaproject/corteza-server:${{ env.BUILD_VERSION }} .
if: ${{ !env.ACT }}
- run: docker push cortezaproject/corteza-server:${{ env.BUILD_VERSION }}
if: ${{ !env.ACT }}