146 lines
4.1 KiB
YAML
146 lines
4.1 KiB
YAML
name: Build
|
|
on:
|
|
workflow_dispatch:
|
|
inputs:
|
|
version:
|
|
type: string
|
|
description: "Version Number"
|
|
push:
|
|
branches:
|
|
- main
|
|
concurrency:
|
|
group: ${{ github.event.inputs.version || github.head_ref || github.ref }}
|
|
cancel-in-progress: true
|
|
jobs:
|
|
metadata:
|
|
runs-on: ubuntu-latest
|
|
name: Metadata
|
|
outputs:
|
|
version: ${{ steps.version.outputs.VERSION }}
|
|
steps:
|
|
- name: Cancel Previous Runs
|
|
uses: styfle/cancel-workflow-action@0.10.0
|
|
with:
|
|
all_but_latest: true
|
|
access_token: ${{ github.token }}
|
|
|
|
- name: Check out repository
|
|
uses: actions/checkout@v3
|
|
with:
|
|
fetch-depth: 0
|
|
- name: Get Version
|
|
id: version
|
|
shell: bash
|
|
run: |
|
|
if [ -z "${INPUT_VERSION}" ]; then
|
|
echo ::set-output name=VERSION::$(git describe --tags | sed 's/\([^-]*-g\)/r\1/;s/-/./g')
|
|
else
|
|
echo ::set-output name=VERSION::${INPUT_VERSION}
|
|
fi
|
|
env:
|
|
INPUT_VERSION: ${{ github.event.inputs.version }}
|
|
- name: ${{ steps.version.outputs.VERSION }}
|
|
shell: bash
|
|
run: |
|
|
echo ${{ steps.version.outputs.VERSION }}
|
|
|
|
build-web:
|
|
runs-on: ubuntu-latest
|
|
name: "Build Web"
|
|
needs:
|
|
- metadata
|
|
steps:
|
|
- name: Check out repository
|
|
uses: actions/checkout@v3
|
|
|
|
- name: Setup node
|
|
uses: actions/setup-node@v3
|
|
with:
|
|
node-version: 16
|
|
cache: "yarn"
|
|
cache-dependency-path: webapp/yarn.lock
|
|
|
|
- name: "Save version number"
|
|
run: echo "REACT_APP_BUILD_VERSION=${{ needs.metadata.outputs.version }}" > ./webapp/.env.production
|
|
|
|
- name: "Build Web"
|
|
run: cd webapp && yarn install && yarn build
|
|
|
|
- name: "Save artifact"
|
|
uses: actions/upload-artifact@v1
|
|
with:
|
|
name: "web-${{ needs.metadata.outputs.version }}"
|
|
path: webapp/build
|
|
|
|
deploy:
|
|
runs-on: ubuntu-latest
|
|
name: Build & Publish ${{ matrix.arch }} / ${{ needs.metadata.outputs.version }}
|
|
if: github.event_name != 'pull_request'
|
|
needs:
|
|
- metadata
|
|
- build-web
|
|
permissions:
|
|
packages: write
|
|
strategy:
|
|
matrix:
|
|
arch:
|
|
- "aarch64"
|
|
- "amd64"
|
|
- "armhf" # see https://github.com/asosnovsky/Shortumation/issues/147
|
|
- "armv7"
|
|
- "i386"
|
|
|
|
steps:
|
|
- name: Check out repository
|
|
uses: actions/checkout@v3
|
|
|
|
# - name: Login to Github Container Registry
|
|
# run: echo ${{ github.token }} | docker login ghcr.io -u ${{ github.repository_owner }} --password-stdin
|
|
- name: Login to DockerHub
|
|
uses: docker/login-action@v2.0.0
|
|
with:
|
|
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
|
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
|
|
|
- name: "Get Web build"
|
|
uses: actions/download-artifact@v1
|
|
with:
|
|
name: "web-${{ needs.metadata.outputs.version }}"
|
|
path: webapp/build
|
|
|
|
- name: ${{ matrix.arch }} / ${{ needs.metadata.outputs.version }}
|
|
uses: home-assistant/builder@master
|
|
# continue-on-error: true
|
|
with:
|
|
args: |
|
|
--${{ matrix.arch }} \
|
|
--no-latest \
|
|
--no-cache \
|
|
--version ${{ needs.metadata.outputs.version }} \
|
|
--target .
|
|
|
|
publish:
|
|
runs-on: ubuntu-latest
|
|
if: "${{ github.event.inputs.version != '' }}"
|
|
needs:
|
|
- metadata
|
|
- deploy
|
|
name: Create Github Pre-Release
|
|
permissions:
|
|
contents: write
|
|
steps:
|
|
- name: Pre-Release ${{ needs.metadata.outputs.version }}
|
|
uses: actions/github-script@v6
|
|
env:
|
|
VERSION: ${{ needs.metadata.outputs.version }}
|
|
CHANGELOG: ${{ needs.metadata.outputs.changlelog }}
|
|
with:
|
|
github-token: ${{ secrets.GITHUB_TOKEN }}
|
|
script: |
|
|
github.rest.repos.createRelease({
|
|
owner: context.repo.owner,
|
|
repo: context.repo.repo,
|
|
tag_name: process.env.VERSION,
|
|
prerelease: true,
|
|
});
|