Skip to content

build

build #29

Workflow file for this run

#
# Copyright (C) 2022 Ing <https://github.com/wjz304>
#
# This is free software, licensed under the MIT License.
# See /LICENSE for more information.
#
name: build
on:
workflow_dispatch:
inputs:
version:
description: "format %y.%-m.$i or auto"
required: false
type: string
jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
target:
- "noarch-7.0"
steps:
- name: Checkout
uses: actions/checkout@main
- name: Init Env
run: |
git config --global user.email "github-actions[bot]@users.noreply.github.com"
git config --global user.name "github-actions[bot]"
sudo timedatectl set-timezone "Asia/Shanghai"
- name: Checkout SynoCommunity Source and Docker Image
run: |
docker pull ghcr.io/synocommunity/spksrc
git clone --depth=1 https://github.com/SynoCommunity/spksrc.git
cp -rf src/* spksrc
- name: Build Package
run: |
ROOT_PATH="${{ github.workspace }}"
MAKE_ARCH="arch-${{ matrix.target }}"
for P in src/spk/*; do \
docker run -v ${ROOT_PATH}/spksrc:/spksrc -w /spksrc/spk/$(basename ${P}) ghcr.io/synocommunity/spksrc make ${MAKE_ARCH}; \
done
- name: Upload to Artifacts
uses: actions/upload-artifact@v7
with:
name: spk-${{ matrix.target }}
path: |
spksrc/packages/*.spk
retention-days: 5
release:
runs-on: ubuntu-latest
needs: build
steps:
- name: Checkout
uses: actions/checkout@main
- name: Init Env
run: |
git config --global user.email "github-actions[bot]@users.noreply.github.com"
git config --global user.name "github-actions[bot]"
sudo timedatectl set-timezone "Asia/Shanghai"
- name: Calculate version
run: |
# Calculate version
VERSION=""
if [ -n "${{ inputs.version }}" ]; then
if [ "$(echo ${{ inputs.version }} | cut -d '.' -f 1,2)" = "$(date +'%y.%-m')" ]; then
VERSION="${{ inputs.version }}"
else
LATEST_TAG="$(curl -skLH "Authorization: token ${{ secrets.RRORG }}" "https://api.github.com/repos/RROrg/syno-driver/releases" | jq -r ".[0].tag_name" 2>/dev/null)"
if [ -n "${LATEST_TAG}" ] && [ "$(echo ${LATEST_TAG} | cut -d '.' -f 1,2)" = "$(date +'%y.%-m')" ]; then # format %y.%-m.$i
VERSION="$(echo ${LATEST_TAG} | awk -F '.' '{$3=$3+1}1' OFS='.')"
else
VERSION="$(date +'%y.%-m').0"
fi
fi
fi
echo "VERSION: ${VERSION}"
echo "VERSION=${VERSION}" >> $GITHUB_ENV
- name: download to artifacts
uses: actions/download-artifact@v8
with:
path: spk
pattern: spk-*
merge-multiple: true
- name: delete-artifact
uses: geekyeggo/delete-artifact@v6
with:
name: |
spk-*
- name: Upload to Artifacts
if: success() && env.VERSION == ''
uses: actions/upload-artifact@v7
with:
name: spk
path: |
spk/*
retention-days: 5
- name: Release
if: env.VERSION != ''
uses: softprops/action-gh-release@v3
with:
tag_name: ${{ env.VERSION }}
files: spk/*