stash/.github/workflows/build.yml

221 lines
8.5 KiB
YAML
Raw Normal View History

2021-02-24 00:26:48 +00:00
name: Build
on:
push:
branches: [ develop, master, files-refactor ]
2021-02-24 00:26:48 +00:00
pull_request:
release:
types: [ published ]
Add golangci-lint workflow (#1759) * Add golangci-lint workflow * Add a bit more lenient linter timeout 1 Minute isn't always enough, so bump to 3. * Document golangci, add make target Document how to get golangci-lint in the README file. While here, provide a QOL target in the makefile for the linter, and make it part of validation. * Introduce .golangci.yml This is the default golangci-lint configuration file location. Use it. Move configuration into the yaml file, and enable the default set of linters; we know we pass most of those. * Add gofmt and revive to golangci-lint Read the golangci-lint source code to figure out the configuration format. Copy the configuration from `revive.toml` into the linter configuration. * Do not set simplify on gofmt The project currently runs without simplify. So for consistency, don't make that a requirement for the linter. * Add new-from-rev Older issues should not be considered a failure for new PRs and issues. Use new-from-from to make the current develop as the point-in-time for when we consider errors. Once in the tree, we can go and fix the older errors in separate patches, taking a little bit at a time. * Move to golangci-lint Rewrite the way we run targets in the makefile, so it is split between frontend and backend. Use the frontend build steps in build.yml Update README to reflect the new world order. * Remove check-gofmt.sh The tool now runs as part of golangci-lint, in particular through the 'validate' target in the Makefile. * Remove targets for golangci-lint Fold these targets into the `lint` target. While here, update README.
2021-09-27 00:41:59 +00:00
concurrency:
group: ${{ github.ref }}
cancel-in-progress: true
env:
COMPILER_IMAGE: stashapp/compiler:6
2021-02-24 00:26:48 +00:00
jobs:
build:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v2
- name: Checkout
run: git fetch --prune --unshallow --tags
- name: Pull compiler image
run: docker pull $COMPILER_IMAGE
2021-02-24 00:26:48 +00:00
- name: Cache node modules
uses: actions/cache@v2
env:
cache-name: cache-node_modules
with:
path: ui/v2.5/node_modules
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('ui/v2.5/yarn.lock') }}
2021-02-24 00:26:48 +00:00
- name: Cache UI build
uses: actions/cache@v2
id: cache-ui
env:
cache-name: cache-ui
with:
path: ui/v2.5/build
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('ui/v2.5/yarn.lock', 'ui/v2.5/public/**', 'ui/v2.5/src/**', 'graphql/**/*.graphql') }}
- name: Cache go build
uses: actions/cache@v2
env:
2021-10-28 06:00:24 +00:00
# increment the number suffix to bump the cache
cache-name: cache-go-cache-1
with:
path: .go-cache
2021-10-28 06:00:24 +00:00
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('go.mod', '**/go.sum') }}
- name: Start build container
env:
official-build: ${{ (github.event_name == 'push' && github.ref == 'refs/heads/develop') || (github.event_name == 'release' && github.ref != 'refs/tags/latest_develop') }}
run: |
mkdir -p .go-cache
docker run -d --name build --mount type=bind,source="$(pwd)",target=/stash,consistency=delegated --mount type=bind,source="$(pwd)/.go-cache",target=/root/.cache/go-build,consistency=delegated --env OFFICIAL_BUILD=${{ env.official-build }} -w /stash $COMPILER_IMAGE tail -f /dev/null
Add golangci-lint workflow (#1759) * Add golangci-lint workflow * Add a bit more lenient linter timeout 1 Minute isn't always enough, so bump to 3. * Document golangci, add make target Document how to get golangci-lint in the README file. While here, provide a QOL target in the makefile for the linter, and make it part of validation. * Introduce .golangci.yml This is the default golangci-lint configuration file location. Use it. Move configuration into the yaml file, and enable the default set of linters; we know we pass most of those. * Add gofmt and revive to golangci-lint Read the golangci-lint source code to figure out the configuration format. Copy the configuration from `revive.toml` into the linter configuration. * Do not set simplify on gofmt The project currently runs without simplify. So for consistency, don't make that a requirement for the linter. * Add new-from-rev Older issues should not be considered a failure for new PRs and issues. Use new-from-from to make the current develop as the point-in-time for when we consider errors. Once in the tree, we can go and fix the older errors in separate patches, taking a little bit at a time. * Move to golangci-lint Rewrite the way we run targets in the makefile, so it is split between frontend and backend. Use the frontend build steps in build.yml Update README to reflect the new world order. * Remove check-gofmt.sh The tool now runs as part of golangci-lint, in particular through the 'validate' target in the Makefile. * Remove targets for golangci-lint Fold these targets into the `lint` target. While here, update README.
2021-09-27 00:41:59 +00:00
2021-02-24 00:26:48 +00:00
- name: Pre-install
run: docker exec -t build /bin/bash -c "make pre-ui"
2021-02-24 00:26:48 +00:00
- name: Generate
run: docker exec -t build /bin/bash -c "make generate"
Add golangci-lint workflow (#1759) * Add golangci-lint workflow * Add a bit more lenient linter timeout 1 Minute isn't always enough, so bump to 3. * Document golangci, add make target Document how to get golangci-lint in the README file. While here, provide a QOL target in the makefile for the linter, and make it part of validation. * Introduce .golangci.yml This is the default golangci-lint configuration file location. Use it. Move configuration into the yaml file, and enable the default set of linters; we know we pass most of those. * Add gofmt and revive to golangci-lint Read the golangci-lint source code to figure out the configuration format. Copy the configuration from `revive.toml` into the linter configuration. * Do not set simplify on gofmt The project currently runs without simplify. So for consistency, don't make that a requirement for the linter. * Add new-from-rev Older issues should not be considered a failure for new PRs and issues. Use new-from-from to make the current develop as the point-in-time for when we consider errors. Once in the tree, we can go and fix the older errors in separate patches, taking a little bit at a time. * Move to golangci-lint Rewrite the way we run targets in the makefile, so it is split between frontend and backend. Use the frontend build steps in build.yml Update README to reflect the new world order. * Remove check-gofmt.sh The tool now runs as part of golangci-lint, in particular through the 'validate' target in the Makefile. * Remove targets for golangci-lint Fold these targets into the `lint` target. While here, update README.
2021-09-27 00:41:59 +00:00
- 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' }}
Add golangci-lint workflow (#1759) * Add golangci-lint workflow * Add a bit more lenient linter timeout 1 Minute isn't always enough, so bump to 3. * Document golangci, add make target Document how to get golangci-lint in the README file. While here, provide a QOL target in the makefile for the linter, and make it part of validation. * Introduce .golangci.yml This is the default golangci-lint configuration file location. Use it. Move configuration into the yaml file, and enable the default set of linters; we know we pass most of those. * Add gofmt and revive to golangci-lint Read the golangci-lint source code to figure out the configuration format. Copy the configuration from `revive.toml` into the linter configuration. * Do not set simplify on gofmt The project currently runs without simplify. So for consistency, don't make that a requirement for the linter. * Add new-from-rev Older issues should not be considered a failure for new PRs and issues. Use new-from-from to make the current develop as the point-in-time for when we consider errors. Once in the tree, we can go and fix the older errors in separate patches, taking a little bit at a time. * Move to golangci-lint Rewrite the way we run targets in the makefile, so it is split between frontend and backend. Use the frontend build steps in build.yml Update README to reflect the new world order. * Remove check-gofmt.sh The tool now runs as part of golangci-lint, in particular through the 'validate' target in the Makefile. * Remove targets for golangci-lint Fold these targets into the `lint` target. While here, update README.
2021-09-27 00:41:59 +00:00
run: docker exec -t build /bin/bash -c "make validate-frontend"
# Static validation happens in the linter workflow in parallel to this workflow
# Run Dynamic validation here, to make sure we pass all the projects integration tests
- name: Test Backend
run: docker exec -t build /bin/bash -c "make it"
2021-02-24 00:26:48 +00:00
- 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: docker exec -t build /bin/bash -c "make ui"
2021-02-24 00:26:48 +00:00
- name: Compile for all supported platforms
run: |
docker exec -t build /bin/bash -c "make cross-compile-windows"
docker exec -t build /bin/bash -c "make cross-compile-macos-intel"
docker exec -t build /bin/bash -c "make cross-compile-macos-applesilicon"
docker exec -t build /bin/bash -c "make cross-compile-linux"
docker exec -t build /bin/bash -c "make cross-compile-linux-arm64v8"
docker exec -t build /bin/bash -c "make cross-compile-linux-arm32v7"
docker exec -t build /bin/bash -c "make cross-compile-linux-arm32v6"
- name: Cleanup build container
run: docker rm -f -v build
2021-02-24 00:26:48 +00:00
- name: Generate checksums
run: |
git describe --tags --exclude latest_develop | tee CHECKSUMS_SHA1
sha1sum dist/stash-* | sed 's/dist\///g' | tee -a CHECKSUMS_SHA1
echo "STASH_VERSION=$(git describe --tags --exclude latest_develop)" >> $GITHUB_ENV
echo "RELEASE_DATE=$(date +'%Y-%m-%d %H:%M:%S %Z')" >> $GITHUB_ENV
Add golangci-lint workflow (#1759) * Add golangci-lint workflow * Add a bit more lenient linter timeout 1 Minute isn't always enough, so bump to 3. * Document golangci, add make target Document how to get golangci-lint in the README file. While here, provide a QOL target in the makefile for the linter, and make it part of validation. * Introduce .golangci.yml This is the default golangci-lint configuration file location. Use it. Move configuration into the yaml file, and enable the default set of linters; we know we pass most of those. * Add gofmt and revive to golangci-lint Read the golangci-lint source code to figure out the configuration format. Copy the configuration from `revive.toml` into the linter configuration. * Do not set simplify on gofmt The project currently runs without simplify. So for consistency, don't make that a requirement for the linter. * Add new-from-rev Older issues should not be considered a failure for new PRs and issues. Use new-from-from to make the current develop as the point-in-time for when we consider errors. Once in the tree, we can go and fix the older errors in separate patches, taking a little bit at a time. * Move to golangci-lint Rewrite the way we run targets in the makefile, so it is split between frontend and backend. Use the frontend build steps in build.yml Update README to reflect the new world order. * Remove check-gofmt.sh The tool now runs as part of golangci-lint, in particular through the 'validate' target in the Makefile. * Remove targets for golangci-lint Fold these targets into the `lint` target. While here, update README.
2021-09-27 00:41:59 +00:00
2021-02-24 00:26:48 +00:00
- name: Upload Windows binary
# only upload binaries for pull requests
if: ${{ github.event_name == 'pull_request' && github.base_ref != 'refs/heads/develop' && github.base_ref != 'refs/heads/master'}}
uses: actions/upload-artifact@v2
with:
name: stash-win.exe
path: dist/stash-win.exe
- name: Upload OSX binary
# only upload binaries for pull requests
if: ${{ github.event_name == 'pull_request' && github.base_ref != 'refs/heads/develop' && github.base_ref != 'refs/heads/master'}}
uses: actions/upload-artifact@v2
with:
name: stash-macos-intel
path: dist/stash-macos-intel
2021-02-24 00:26:48 +00:00
- name: Upload Linux binary
# only upload binaries for pull requests
if: ${{ github.event_name == 'pull_request' && github.base_ref != 'refs/heads/develop' && github.base_ref != 'refs/heads/master'}}
uses: actions/upload-artifact@v2
with:
name: stash-linux
path: dist/stash-linux
Add golangci-lint workflow (#1759) * Add golangci-lint workflow * Add a bit more lenient linter timeout 1 Minute isn't always enough, so bump to 3. * Document golangci, add make target Document how to get golangci-lint in the README file. While here, provide a QOL target in the makefile for the linter, and make it part of validation. * Introduce .golangci.yml This is the default golangci-lint configuration file location. Use it. Move configuration into the yaml file, and enable the default set of linters; we know we pass most of those. * Add gofmt and revive to golangci-lint Read the golangci-lint source code to figure out the configuration format. Copy the configuration from `revive.toml` into the linter configuration. * Do not set simplify on gofmt The project currently runs without simplify. So for consistency, don't make that a requirement for the linter. * Add new-from-rev Older issues should not be considered a failure for new PRs and issues. Use new-from-from to make the current develop as the point-in-time for when we consider errors. Once in the tree, we can go and fix the older errors in separate patches, taking a little bit at a time. * Move to golangci-lint Rewrite the way we run targets in the makefile, so it is split between frontend and backend. Use the frontend build steps in build.yml Update README to reflect the new world order. * Remove check-gofmt.sh The tool now runs as part of golangci-lint, in particular through the 'validate' target in the Makefile. * Remove targets for golangci-lint Fold these targets into the `lint` target. While here, update README.
2021-09-27 00:41:59 +00:00
2021-02-24 03:36:39 +00:00
- name: Update latest_develop tag
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/develop' }}
run : git tag -f latest_develop; git push -f --tags
2021-02-24 00:26:48 +00:00
- name: Update files-refactor-release tag
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/files-refactor' }}
run : git tag -f files-refactor-release; git push -f --tags
2021-02-24 00:26:48 +00:00
- name: Development Release
Add golangci-lint workflow (#1759) * Add golangci-lint workflow * Add a bit more lenient linter timeout 1 Minute isn't always enough, so bump to 3. * Document golangci, add make target Document how to get golangci-lint in the README file. While here, provide a QOL target in the makefile for the linter, and make it part of validation. * Introduce .golangci.yml This is the default golangci-lint configuration file location. Use it. Move configuration into the yaml file, and enable the default set of linters; we know we pass most of those. * Add gofmt and revive to golangci-lint Read the golangci-lint source code to figure out the configuration format. Copy the configuration from `revive.toml` into the linter configuration. * Do not set simplify on gofmt The project currently runs without simplify. So for consistency, don't make that a requirement for the linter. * Add new-from-rev Older issues should not be considered a failure for new PRs and issues. Use new-from-from to make the current develop as the point-in-time for when we consider errors. Once in the tree, we can go and fix the older errors in separate patches, taking a little bit at a time. * Move to golangci-lint Rewrite the way we run targets in the makefile, so it is split between frontend and backend. Use the frontend build steps in build.yml Update README to reflect the new world order. * Remove check-gofmt.sh The tool now runs as part of golangci-lint, in particular through the 'validate' target in the Makefile. * Remove targets for golangci-lint Fold these targets into the `lint` target. While here, update README.
2021-09-27 00:41:59 +00:00
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/develop' }}
2021-05-01 01:19:21 +00:00
uses: marvinpinto/action-automatic-releases@v1.1.2
2021-02-24 00:26:48 +00:00
with:
2021-05-01 01:19:21 +00:00
repo_token: "${{ secrets.GITHUB_TOKEN }}"
2021-02-24 00:26:48 +00:00
prerelease: true
2021-05-01 01:19:21 +00:00
automatic_release_tag: latest_develop
title: "${{ env.STASH_VERSION }}: Latest development build"
2021-02-24 00:26:48 +00:00
files: |
dist/stash-macos-intel
dist/stash-macos-applesilicon
2021-02-24 00:26:48 +00:00
dist/stash-win.exe
dist/stash-linux
dist/stash-linux-arm64v8
dist/stash-linux-arm32v7
dist/stash-linux-arm32v6
2021-02-24 00:26:48 +00:00
CHECKSUMS_SHA1
Add golangci-lint workflow (#1759) * Add golangci-lint workflow * Add a bit more lenient linter timeout 1 Minute isn't always enough, so bump to 3. * Document golangci, add make target Document how to get golangci-lint in the README file. While here, provide a QOL target in the makefile for the linter, and make it part of validation. * Introduce .golangci.yml This is the default golangci-lint configuration file location. Use it. Move configuration into the yaml file, and enable the default set of linters; we know we pass most of those. * Add gofmt and revive to golangci-lint Read the golangci-lint source code to figure out the configuration format. Copy the configuration from `revive.toml` into the linter configuration. * Do not set simplify on gofmt The project currently runs without simplify. So for consistency, don't make that a requirement for the linter. * Add new-from-rev Older issues should not be considered a failure for new PRs and issues. Use new-from-from to make the current develop as the point-in-time for when we consider errors. Once in the tree, we can go and fix the older errors in separate patches, taking a little bit at a time. * Move to golangci-lint Rewrite the way we run targets in the makefile, so it is split between frontend and backend. Use the frontend build steps in build.yml Update README to reflect the new world order. * Remove check-gofmt.sh The tool now runs as part of golangci-lint, in particular through the 'validate' target in the Makefile. * Remove targets for golangci-lint Fold these targets into the `lint` target. While here, update README.
2021-09-27 00:41:59 +00:00
2021-02-24 00:26:48 +00:00
- name: Master release
# NOTE: this isn't perfect, but should cover most scenarios
# DON'T create tag names starting with "v" if they are not stable releases
2022-07-26 04:42:18 +00:00
if: ${{ github.event_name == 'release' && startsWith(github.ref, 'refs/tags/v') }}
2022-03-08 00:10:56 +00:00
uses: WithoutPants/github-release@v2.0.4
2021-02-24 00:26:48 +00:00
with:
token: "${{ secrets.GITHUB_TOKEN }}"
2021-03-29 01:59:03 +00:00
allow_override: true
2021-02-24 00:26:48 +00:00
files: |
dist/stash-macos-intel
dist/stash-macos-applesilicon
2021-02-24 00:26:48 +00:00
dist/stash-win.exe
dist/stash-linux
dist/stash-linux-arm64v8
dist/stash-linux-arm32v7
dist/stash-linux-arm32v6
2021-02-24 00:26:48 +00:00
CHECKSUMS_SHA1
gzip: false
Add golangci-lint workflow (#1759) * Add golangci-lint workflow * Add a bit more lenient linter timeout 1 Minute isn't always enough, so bump to 3. * Document golangci, add make target Document how to get golangci-lint in the README file. While here, provide a QOL target in the makefile for the linter, and make it part of validation. * Introduce .golangci.yml This is the default golangci-lint configuration file location. Use it. Move configuration into the yaml file, and enable the default set of linters; we know we pass most of those. * Add gofmt and revive to golangci-lint Read the golangci-lint source code to figure out the configuration format. Copy the configuration from `revive.toml` into the linter configuration. * Do not set simplify on gofmt The project currently runs without simplify. So for consistency, don't make that a requirement for the linter. * Add new-from-rev Older issues should not be considered a failure for new PRs and issues. Use new-from-from to make the current develop as the point-in-time for when we consider errors. Once in the tree, we can go and fix the older errors in separate patches, taking a little bit at a time. * Move to golangci-lint Rewrite the way we run targets in the makefile, so it is split between frontend and backend. Use the frontend build steps in build.yml Update README to reflect the new world order. * Remove check-gofmt.sh The tool now runs as part of golangci-lint, in particular through the 'validate' target in the Makefile. * Remove targets for golangci-lint Fold these targets into the `lint` target. While here, update README.
2021-09-27 00:41:59 +00:00
- name: Files refactor Release
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/files-refactor' }}
uses: softprops/action-gh-release@v1
with:
token: "${{ secrets.GITHUB_TOKEN }}"
prerelease: true
tag_name: files-refactor-release
target_commitish: refs/heads/files-refactor
files: |
dist/stash-macos-intel
dist/stash-macos-applesilicon
dist/stash-win.exe
dist/stash-linux
dist/stash-linux-arm64v8
dist/stash-linux-arm32v7
dist/stash-linux-arm32v6
CHECKSUMS_SHA1
2021-02-24 00:26:48 +00:00
- name: Development Docker
2022-03-08 00:10:56 +00:00
if: ${{ github.repository == 'stashapp/stash' && github.event_name == 'push' && github.ref == 'refs/heads/develop' }}
2021-02-24 00:26:48 +00:00
env:
DOCKER_CLI_EXPERIMENTAL: enabled
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
run: |
Add golangci-lint workflow (#1759) * Add golangci-lint workflow * Add a bit more lenient linter timeout 1 Minute isn't always enough, so bump to 3. * Document golangci, add make target Document how to get golangci-lint in the README file. While here, provide a QOL target in the makefile for the linter, and make it part of validation. * Introduce .golangci.yml This is the default golangci-lint configuration file location. Use it. Move configuration into the yaml file, and enable the default set of linters; we know we pass most of those. * Add gofmt and revive to golangci-lint Read the golangci-lint source code to figure out the configuration format. Copy the configuration from `revive.toml` into the linter configuration. * Do not set simplify on gofmt The project currently runs without simplify. So for consistency, don't make that a requirement for the linter. * Add new-from-rev Older issues should not be considered a failure for new PRs and issues. Use new-from-from to make the current develop as the point-in-time for when we consider errors. Once in the tree, we can go and fix the older errors in separate patches, taking a little bit at a time. * Move to golangci-lint Rewrite the way we run targets in the makefile, so it is split between frontend and backend. Use the frontend build steps in build.yml Update README to reflect the new world order. * Remove check-gofmt.sh The tool now runs as part of golangci-lint, in particular through the 'validate' target in the Makefile. * Remove targets for golangci-lint Fold these targets into the `lint` target. While here, update README.
2021-09-27 00:41:59 +00:00
docker run --rm --privileged docker/binfmt:a7996909642ee92942dcd6cff44b9b95f08dad64
2021-02-24 00:26:48 +00:00
docker info
docker buildx create --name builder --use
docker buildx inspect --bootstrap
docker buildx ls
bash ./docker/ci/x86_64/docker_push.sh development
- name: Release Docker
# NOTE: this isn't perfect, but should cover most scenarios
# DON'T create tag names starting with "v" if they are not stable releases
2022-07-26 04:42:18 +00:00
if: ${{ github.repository == 'stashapp/stash' && github.event_name == 'release' && startsWith(github.ref, 'refs/tags/v') }}
2021-02-24 00:26:48 +00:00
env:
DOCKER_CLI_EXPERIMENTAL: enabled
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
run: |
Add golangci-lint workflow (#1759) * Add golangci-lint workflow * Add a bit more lenient linter timeout 1 Minute isn't always enough, so bump to 3. * Document golangci, add make target Document how to get golangci-lint in the README file. While here, provide a QOL target in the makefile for the linter, and make it part of validation. * Introduce .golangci.yml This is the default golangci-lint configuration file location. Use it. Move configuration into the yaml file, and enable the default set of linters; we know we pass most of those. * Add gofmt and revive to golangci-lint Read the golangci-lint source code to figure out the configuration format. Copy the configuration from `revive.toml` into the linter configuration. * Do not set simplify on gofmt The project currently runs without simplify. So for consistency, don't make that a requirement for the linter. * Add new-from-rev Older issues should not be considered a failure for new PRs and issues. Use new-from-from to make the current develop as the point-in-time for when we consider errors. Once in the tree, we can go and fix the older errors in separate patches, taking a little bit at a time. * Move to golangci-lint Rewrite the way we run targets in the makefile, so it is split between frontend and backend. Use the frontend build steps in build.yml Update README to reflect the new world order. * Remove check-gofmt.sh The tool now runs as part of golangci-lint, in particular through the 'validate' target in the Makefile. * Remove targets for golangci-lint Fold these targets into the `lint` target. While here, update README.
2021-09-27 00:41:59 +00:00
docker run --rm --privileged docker/binfmt:a7996909642ee92942dcd6cff44b9b95f08dad64
2021-02-24 00:26:48 +00:00
docker info
docker buildx create --name builder --use
docker buildx inspect --bootstrap
docker buildx ls
bash ./docker/ci/x86_64/docker_push.sh latest "${{ github.event.release.tag_name }}"