Skip to content

Commit

Permalink
try switching ci
Browse files Browse the repository at this point in the history
  • Loading branch information
rcannood committed Sep 8, 2024
1 parent 37fde11 commit b782e93
Show file tree
Hide file tree
Showing 4 changed files with 127 additions and 244 deletions.
126 changes: 126 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
name: Build

on:
push:
branches: [ 'main' ]
workflow_dispatch:
inputs:
version:
description: Version tag
required: true

jobs:
# phase 1
list:
runs-on: ubuntu-latest

outputs:
target_branch: ${{ steps.variables.outputs.target_branch }}
version: ${{ steps.variables.outputs.version }}
docker_matrix: ${{ steps.ns_list_docker.outputs.output_matrix }}

steps:
- name: Check out repository
uses: actions/checkout@v4
with:
submodules: 'recursive'
fetch-depth: 0

- uses: viash-io/viash-actions/setup@v6

- name: Determine variables
id: variables
run: |
VERSION="${{ inputs.version }}"
SOURCE_BRANCH=$(echo "$GITHUB_REF" | sed 's/refs\/heads\///')
if [[ -z $VERSION ]]; then
TARGET_BRANCH="build/$SOURCE_BRANCH"
VERSION=$(echo "$TARGET_BRANCH" | sed 's/[^a-zA-Z0-9_]/_/g')
else
if [[ ! "$VERSION" =~ ^[0-9]+\.[0-9]+\.[0-9]+.*$ ]]; then
echo "Version '$VERSION' does not match PEP440"
exit 1
fi
TARGET_BRANCH="release/${VERSION%.*}.x"
fi
echo "Set version of Viash package to '$VERSION'"
echo "version=$VERSION" >> $GITHUB_OUTPUT
echo "Set target branch to '$TARGET_BRANCH'"
echo "target_branch=$TARGET_BRANCH" >> $GITHUB_OUTPUT
- name: Remove target folder from .gitignore
run: |
# allow publishing the target folder
sed -i 's#^/target/$##g' .gitignore
- uses: viash-io/viash-actions/ns-build@v6
with:
config_mod: .functionality.version := '${{ steps.variables.outputs.version }}'
parallel: true

- name: Deploy to target branch
uses: peaceiris/actions-gh-pages@v4
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: .
publish_branch: ${{ steps.variables.outputs.target_branch }}

- id: ns_list_docker
uses: viash-io/viash-actions/ns-list@v6
with:
platform: docker
src: src
format: json

# phase 2
build:
needs: list

runs-on: ubuntu-latest

permissions:
contents: read
packages: write

strategy:
fail-fast: false
matrix:
component: ${{ fromJson(needs.list.outputs.docker_matrix) }}

steps:
# Remove unnecessary files to free up space. Otherwise, we get 'no space left on device.'
- uses: data-intuitive/reclaim-the-bytes@v2

- uses: actions/checkout@v4
with:
submodules: 'recursive'
fetch-depth: 0
ref: ${{ needs.list.outputs.target_branch }}

- uses: viash-io/viash-actions/setup@v6

- name: Build container
uses: viash-io/viash-actions/ns-build@v6
with:
config_mod: .functionality.version := '${{ needs.list.outputs.version }}'
platform: docker
src: ${{ matrix.component.dir }}
setup: build

- name: Login to container registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Push container
uses: viash-io/viash-actions/ns-build@v6
with:
config_mod: .functionality.version := '${{ needs.list.outputs.version }}'
platform: docker
src: ${{ matrix.component.dir }}
setup: push
97 changes: 0 additions & 97 deletions .github/workflows/main-build.yml

This file was deleted.

146 changes: 0 additions & 146 deletions .github/workflows/release-build.yml

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: viash test
name: Test

on:
pull_request:
Expand Down

0 comments on commit b782e93

Please sign in to comment.