Skip to content

build

build #235

Workflow file for this run

name: build
on:
workflow_dispatch:
schedule:
- cron: '0 20 * * *'
env:
app_name: lat
app_repo: lat-opensource/lat
jobs:
check-binaries:
runs-on: ubuntu-latest
outputs:
app_version: ${{ steps.get-version.outputs.app_version }}
app_build: ${{ steps.check-release.outputs.app_build }}
steps:
- uses: actions/checkout@v4
- uses: docker/setup-buildx-action@v3
- name: Get Version
id: get-version
run: |
app_version=$(curl -sSL "https://github.com/${{ env.app_repo }}/raw/refs/heads/master/VERSION")
if [ -z "${app_version}" ] || [ "${app_version}" == "null" ]; then
echo "Failed to get version"
exit 1
fi
echo "app_version=${app_version}" >> $GITHUB_ENV
echo "app_version=${app_version}" >> $GITHUB_OUTPUT
echo ""
echo "========== Build Args =========="
echo "app_version=${app_version}"
- name: Check Release
id: check-release
run: |
gh release view ${app_version} -R ${{ github.repository }} >/dev/null 2>&1 || echo "create=1" >> $GITHUB_OUTPUT
gh release view ${app_version} -R ${{ github.repository }} | grep ${{ env.app_name }}-.* >/dev/null 2>&1 || echo "app_build=1" >> $GITHUB_OUTPUT
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Create Tag
if : steps.check-release.outputs.create == '1'
run: |
git config --global user.name "${GITHUB_ACTOR}"
git config --global user.email "${GITHUB_ACTOR}@users.noreply.github.com"
git add .
git commit -m "Release ${app_version}" || true
git tag ${app_version}
git push origin ${app_version} || true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Create Release
if : steps.check-release.outputs.create == '1'
run: |
gh release create ${app_version} -R ${{ github.repository }} --title ${app_version} --generate-notes
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
build-binaries:
runs-on: ubuntu-latest
needs: check-binaries
if: ${{ needs.check-binaries.outputs.app_build == '1' }}
env:
app_version: ${{ needs.check-binaries.outputs.app_version }}
strategy:
fail-fast: false
matrix:
os: [ 'debian' ]
# suite: [ 'trixie', 'forky' ]
suite: [ 'trixie' ]
steps:
- uses: actions/checkout@v4
- uses: docker/setup-qemu-action@v3
- uses: docker/setup-buildx-action@v3
- name: Cache Docker layers
uses: actions/cache@v4
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-${{ env.app_name }}-${{ matrix.os }}-${{ matrix.suite }}-build-${{ github.sha }}
restore-keys: |
${{ runner.os }}-${{ env.app_name }}-${{ matrix.os }}-${{ matrix.suite }}-build-
${{ runner.os }}-buildx-
- name: Build Binaries
run: |
docker buildx build --platform linux/loong64 --build-arg BASE_IMAGE=ghcr.io/loong64/${{ matrix.os }}:${{ matrix.suite }}-slim --build-arg VERSION=${{ env.app_version }} -t ${{ env.app_name }}-${{ matrix.os }}-${{ matrix.suite }}:${{ env.app_version }}-loong64 --cache-from=type=local,src=/tmp/.buildx-cache --cache-to=type=local,dest=/tmp/.buildx-cache-new,mode=max . --load
- name: Upgrade Release
run: |
docker run --rm -v $(pwd)/dist:/dist ${{ env.app_name }}-${{ matrix.os }}-${{ matrix.suite }}:${{ env.app_version }}-loong64
ls -al dist
gh release upload ${{ env.app_version }} -R ${{ github.repository }} dist/*
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Move cache
run: |
rm -rf /tmp/.buildx-cache
mv /tmp/.buildx-cache-new /tmp/.buildx-cache