Refactor application structure and query layer #1909
Workflow file for this run
This file contains hidden or 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-24.04 | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Build custom PostgreSQL image | |
| run: docker build -t stash-box-postgres -f docker/production/postgres/Dockerfile docker/production/postgres | |
| - name: Start PostgreSQL container | |
| run: | | |
| docker run -d \ | |
| --name postgres \ | |
| -e POSTGRES_DB=postgres \ | |
| -e POSTGRES_PASSWORD=postgres \ | |
| -e POSTGRES_USER=postgres \ | |
| -p 5432:5432 \ | |
| --health-cmd pg_isready \ | |
| --health-interval 10s \ | |
| --health-timeout 5s \ | |
| --health-retries 5 \ | |
| stash-box-postgres | |
| - name: Wait for PostgreSQL to be ready | |
| run: | | |
| until docker exec postgres pg_isready; do | |
| echo "Waiting for postgres..." | |
| sleep 2 | |
| done | |
| - name: Install vips | |
| run: sudo apt-get update && sudo apt-get install -y libvips-dev | |
| - name: Install Go | |
| uses: actions/setup-go@v5 | |
| with: | |
| go-version: 1.25.x | |
| - name: Install Node | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: '22' | |
| - name: Install PNPM | |
| uses: pnpm/action-setup@v4 | |
| with: | |
| version: 9 | |
| - name: Install sqlc | |
| uses: sqlc-dev/setup-sqlc@v4 | |
| with: | |
| sqlc-version: '1.29.0' | |
| - name: Cache node modules | |
| uses: actions/cache@v4 | |
| env: | |
| cache-name: cache-node_modules | |
| with: | |
| path: frontend/node_modules | |
| key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('frontend/pnpm-lock.yaml') }} | |
| - name: Cache UI build | |
| uses: actions/cache@v4 | |
| id: cache-ui | |
| env: | |
| cache-name: cache-ui | |
| with: | |
| path: frontend/build | |
| key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('frontend/pnpm-lock.yaml', 'frontend/vite.config.js', 'frontend/src/**', 'graphql/**/*.graphql') }} | |
| - name: Cache go build | |
| uses: actions/cache@v4 | |
| 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 | |
| run: make generate | |
| - name: Check generated files | |
| run: | | |
| go mod tidy | |
| if ! git diff --exit-code; then | |
| echo "::error::Generated files have changed. Run 'make generate' locally and commit the changes." | |
| git diff | |
| exit 1 | |
| fi | |
| - 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@v4 | |
| 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@v4 | |
| 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@v3 | |
| 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 |