v0.5.1 #1469
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Build | |
on: | |
push: | |
branches: [ master ] | |
pull_request: | |
branches: [ master ] | |
release: | |
types: [ published ] | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.ref }} | |
cancel-in-progress: true | |
jobs: | |
build: | |
runs-on: ubuntu-22.04 | |
services: | |
postgres: | |
image: postgres:16.1 | |
env: | |
POSTGRES_DB: postgres | |
POSTGRES_PASSWORD: postgres | |
POSTGRES_USER: postgres | |
ports: | |
- 5432:5432 | |
# Set health checks to wait until postgres has started | |
options: >- | |
--health-cmd pg_isready | |
--health-interval 10s | |
--health-timeout 5s | |
--health-retries 5 | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
- name: Install Go | |
uses: actions/setup-go@v3 | |
with: | |
go-version: 1.22.x | |
- name: Install Node | |
uses: actions/setup-node@v2 | |
with: | |
node-version: '20' | |
- name: Cache node modules | |
uses: actions/cache@v2 | |
env: | |
cache-name: cache-node_modules | |
with: | |
path: frontend/node_modules | |
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('frontend/yarn.lock') }} | |
- name: Cache UI build | |
uses: actions/cache@v2 | |
id: cache-ui | |
env: | |
cache-name: cache-ui | |
with: | |
path: frontend/build | |
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('frontend/yarn.lock', 'frontend/vite.config.js', 'frontend/src/**', 'graphql/**/*.graphql') }} | |
- name: Cache go build | |
uses: actions/cache@v2 | |
env: | |
cache-name: cache-go-cache-2 | |
with: | |
path: | | |
~/go/pkg/mod | |
.go-cache | |
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('go.mod', '**/go.sum') }} | |
- name: Pre-install | |
run: make pre-ui | |
- name: Generate | |
# Make sure generate does not need to be run | |
run: | | |
make generate | |
git add --intent-to-add . | |
git diff --stat --exit-code | |
- name: Validate UI | |
# skip UI validation for pull requests if UI is unchanged | |
if: ${{ github.event_name != 'pull_request' || steps.cache-ui.outputs.cache-hit != 'true' }} | |
run: make ui-validate | |
- name: Build UI | |
# skip UI build for pull requests if UI is unchanged (UI was cached) | |
# this means that the build version/time may be incorrect if the UI is | |
# not changed in a pull request | |
if: ${{ github.event_name != 'pull_request' || steps.cache-ui.outputs.cache-hit != 'true' }} | |
run: make ui | |
- name: Run tests | |
env: | |
POSTGRES_DB: postgres:postgres@localhost/postgres?sslmode=disable | |
run: make it | |
- name: Set PR version | |
if: ${{ github.event_name == 'pull_request' && github.base_ref != 'refs/heads/master'}} | |
run: echo "BUILD_TYPE=PR" >> $GITHUB_ENV | |
- name: Set Official version | |
if: ${{ github.event_name == 'release' && github.ref != 'refs/tags/latest-develop' }} | |
run: echo "BUILD_TYPE=OFFICIAL" >> $GITHUB_ENV | |
- name: Set Development version | |
if: ${{ github.event_name == 'push' }} | |
run: echo "BUILD_TYPE=DEVELOPMENT" >> $GITHUB_ENV | |
- name: Crosscompile binaries | |
run: make cross-compile | |
env: | |
BUILD_TYPE: "${{ env.BUILD_TYPE }}" | |
- name: Generate checksums | |
run: | | |
git describe --tags --exclude latest-develop | tee CHECKSUMS_SHA1 | |
sha1sum dist/stash-box-* | sed 's/dist\/.*\///g' | tee -a CHECKSUMS_SHA1 | |
echo "STASH_BOX_VERSION=$(git describe --tags --exclude latest-develop)" >> $GITHUB_ENV | |
- name: Upload Windows binary | |
# only upload binaries for pull requests | |
if: ${{ github.event_name == 'pull_request' && github.base_ref != 'refs/heads/master'}} | |
uses: actions/upload-artifact@v2 | |
with: | |
name: stash-box-win.exe | |
path: dist/stash-box-windows.exe | |
- name: Upload Linux binary | |
# only upload binaries for pull requests | |
if: ${{ github.event_name == 'pull_request' && github.base_ref != 'refs/heads/master'}} | |
uses: actions/upload-artifact@v2 | |
with: | |
name: stash-box-linux | |
path: dist/stash-box-linux | |
- name: Update latest-develop tag | |
if: ${{ github.event_name == 'push' }} | |
run : git tag -f latest-develop; git push -f --tags | |
- name: Development Release | |
if: ${{ github.event_name == 'push' }} | |
uses: marvinpinto/[email protected] | |
with: | |
repo_token: "${{ secrets.GITHUB_TOKEN }}" | |
prerelease: true | |
automatic_release_tag: latest-develop | |
title: "${{ env.STASH_BOX_VERSION }}: Latest development build" | |
files: | | |
dist/stash-box-windows.exe | |
dist/stash-box-linux | |
CHECKSUMS_SHA1 | |
- name: Master release | |
if: ${{ github.event_name == 'release' && github.ref != 'refs/tags/latest-develop' }} | |
uses: WithoutPants/[email protected] | |
with: | |
token: "${{ secrets.GITHUB_TOKEN }}" | |
allow_override: true | |
files: | | |
dist/stash-box-windows.exe | |
dist/stash-box-linux | |
CHECKSUMS_SHA1 | |
gzip: false | |
- name: Login to DockerHub | |
if: ${{ github.event_name != 'pull_request' }} | |
uses: docker/login-action@v1 | |
with: | |
username: ${{ secrets.DOCKERHUB_USERNAME }} | |
password: ${{ secrets.DOCKERHUB_TOKEN }} | |
- name: Development Docker | |
if: ${{ github.event_name == 'push' }} | |
run: | | |
docker build -t stashapp/stash-box:development -f ./docker/ci/x86_64/Dockerfile ./dist | |
docker push stashapp/stash-box:development | |
- name: Release Docker | |
if: ${{ github.event_name == 'release' && github.ref != 'refs/tags/latest-develop' }} | |
run: | | |
docker build -t stashapp/stash-box:latest -f ./docker/ci/x86_64/Dockerfile ./dist | |
docker push stashapp/stash-box:latest |