Skip to content

Expand app version number #298

Expand app version number

Expand app version number #298

Workflow file for this run

name: Test & Release
on:
push:
branches:
- master
- dev
pull_request:
branches:
- master
- dev
jobs:
test:
name: test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- uses: FedericoCarboni/setup-ffmpeg@v2
- uses: actions/setup-go@v4
with:
go-version: '1.22.x'
id: go
- name: Retrieve release details
id: release_details
run: |
echo "APP_NAME=$(git describe --tags|sed -e 's/\-v.*//')" >> $GITHUB_ENV
echo "APP_VERSION=$(git describe --tags --match 'api-v*'|sed 's/api-v\([0-9.]*\)/\1/')" >> $GITHUB_ENV
- name: Release details
run: |
echo "::group::app ${{ env.APP_NAME }}"
echo "version ${{ env.APP_VERSION }}"
echo "env ${{ github.ref }}"
echo "::endgroup::"
- name: Set up containers
run: docker compose up -d
- name: Set up containers
run: docker compose -f apps/watchman/docker-compose.yml up -d clickhouse geoipupdate
- name: Check running containers
run: docker ps -a
- name: Prepare for tests
run: make prepare_test
- name: Wait for wallet init
run: scripts/wait_for_wallet.sh
- name: Test
env:
OAUTH_TEST_CLIENT_SECRET: ${{ secrets.OAUTH_TEST_CLIENT_SECRET }}
OAUTH_TEST_USERNAME: ${{ secrets.OAUTH_TEST_USERNAME }}
OAUTH_TEST_PASSWORD: ${{ secrets.OAUTH_TEST_PASSWORD }}
REAL_WALLET_PRIVATE_KEY: ${{ secrets.REAL_WALLET_PRIVATE_KEY }}
REAL_WALLET_PUBLIC_KEY: ${{ secrets.REAL_WALLET_PUBLIC_KEY }}
BUYER_WALLET_PRIVATE_KEY: ${{ secrets.BUYER_WALLET_PRIVATE_KEY }}
BUYER_WALLET_PUBLIC_KEY: ${{ secrets.BUYER_WALLET_PUBLIC_KEY }}
REFLECTOR_UPLINK: ${{ secrets.REFLECTOR_UPLINK }}
run: |
go install github.com/jandelgado/gcov2lcov@latest
go test -short -covermode=count -coverprofile=coverage.out ./... && gcov2lcov -infile=coverage.out -outfile=coverage.lcov
- uses: coverallsapp/github-action@v2
with:
file: coverage.lcov
github-token: ${{ secrets.GITHUB_TOKEN }}
release:
name: release
needs: test
if: github.ref == 'refs/heads/master' || github.ref == 'refs/heads/dev'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- uses: actions/setup-go@v4
with:
go-version: '1.22.x'
id: go
- run: git branch
- name: Retrieve release details
id: release
run: |
echo "APP_NAME=$(git describe --tags|sed -e 's/\-v.*//')" >> $GITHUB_OUTPUT
echo "APP_VERSION=$(git describe --tags|sed 's/api-v\([0-9.]*\)-.*/\1/')" >> $GITHUB_OUTPUT
- name: Release details
run: |
echo "::group::${{ steps.release.outputs.APP_NAME }}"
echo "version ${{ steps.release.outputs.APP_VERSION }}"
echo "env ${{ github.ref }}"
echo "::endgroup::"
- name: Login to DockerHub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
# odysee-api deployment
- name: Build odysee-api
if: steps.release.outputs.APP_NAME == 'api'
run: make oapi
- name: Build and push odysee-api docker image
if: steps.release.outputs.APP_NAME == 'api'
uses: docker/build-push-action@v2
with:
push: true
context: .
tags: |
odyseeteam/odysee-${{ steps.release.outputs.APP_NAME }}:latest
odyseeteam/odysee-${{ steps.release.outputs.APP_NAME }}:${{ steps.release.outputs.APP_VERSION }}
- name: Deploy odysee-api
if: steps.release.outputs.APP_NAME == 'api'
uses: octokit/[email protected]
id: deploy-odysee-api
env:
GITHUB_TOKEN: ${{ secrets.DEPLOYMENT_REPO_TOKEN }}
with:
route: POST /repos/:repository/dispatches
repository: odyseeteam/misc-deployment
event_type: deploy-odysee
client_payload: |
tag: ${{ steps.release.outputs.APP_VERSION }}
ref: ${{ github.ref }}
service: odysee-api
# Watchman deployment
- name: Build watchman
if: steps.release.outputs.APP_NAME == 'watchman'
run: make watchman
- name: Build watchman docker image
if: steps.release.outputs.APP_NAME == 'watchman'
uses: docker/build-push-action@v2
with:
push: true
context: apps/${{ steps.release.outputs.APP_NAME }}/
tags: |
odyseeteam/${{ steps.release.outputs.APP_NAME }}:latest
odyseeteam/${{ steps.release.outputs.APP_NAME }}:${{ steps.release.outputs.APP_VERSION }}
file: apps/${{ steps.release.outputs.APP_NAME }}/Dockerfile
- name: Deploy watchman
if: steps.release.outputs.APP_NAME == 'watchman'
uses: octokit/[email protected]
id: deploy-watchman
env:
GITHUB_TOKEN: ${{ secrets.DEPLOYMENT_REPO_TOKEN }}
with:
route: POST /repos/:repository/dispatches
repository: OdyseeTeam/misc-deployment
event_type: deploy-odysee
client_payload: |
tag: ${{ steps.release.outputs.APP_VERSION }}
ref: ${{ github.ref }}
service: ${{ steps.release.outputs.APP_NAME }}