133 lines
4.5 KiB
YAML
133 lines
4.5 KiB
YAML
name: Build packages
|
|
on:
|
|
push:
|
|
tags:
|
|
- '*'
|
|
workflow_dispatch:
|
|
inputs:
|
|
release_tag:
|
|
description: Release tag to build and publish
|
|
required: true
|
|
type: string
|
|
|
|
permissions:
|
|
contents: write
|
|
|
|
jobs:
|
|
preparation:
|
|
name: Setup build version
|
|
runs-on: ubuntu-latest
|
|
outputs:
|
|
version: ${{ steps.version.outputs.version }}
|
|
steps:
|
|
- uses: actions/checkout@v5.0.0
|
|
with:
|
|
fetch-depth: 0
|
|
- id: version
|
|
shell: bash
|
|
run: |
|
|
INPUT_VERSION="${{ inputs.release_tag || '' }}"
|
|
if [ -n "$INPUT_VERSION" ]; then
|
|
VERSION="$INPUT_VERSION"
|
|
else
|
|
VERSION=$(git describe --tags --exact-match 2>/dev/null || echo "0.$(date +%d%m%Y)")
|
|
fi
|
|
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
|
|
|
|
build:
|
|
name: Builder for ${{ matrix.package_type }} Podkop Plus packages
|
|
runs-on: ubuntu-latest
|
|
needs: preparation
|
|
strategy:
|
|
matrix:
|
|
include:
|
|
- { package_type: ipk }
|
|
- { package_type: apk }
|
|
steps:
|
|
- uses: actions/checkout@v5.0.0
|
|
with:
|
|
fetch-depth: 0
|
|
|
|
- name: Build ${{ matrix.package_type }}
|
|
uses: docker/build-push-action@v6.18.0
|
|
with:
|
|
file: ./Dockerfile-${{ matrix.package_type }}
|
|
context: .
|
|
tags: podkop-plus:ci-${{ matrix.package_type }}
|
|
build-args: |
|
|
PODKOP_VERSION=${{ needs.preparation.outputs.version }}
|
|
|
|
- name: Create ${{ matrix.package_type }} Docker container
|
|
run: docker create --name ${{ matrix.package_type }} podkop-plus:ci-${{ matrix.package_type }}
|
|
|
|
- name: Copy files from ${{ matrix.package_type }} Docker container
|
|
run: |
|
|
mkdir -p ./bin/${{ matrix.package_type }}
|
|
docker cp ${{ matrix.package_type }}:/builder/bin/packages/x86_64/utilities/. ./bin/${{ matrix.package_type }}/
|
|
docker cp ${{ matrix.package_type }}:/builder/bin/packages/x86_64/luci/. ./bin/${{ matrix.package_type }}/
|
|
|
|
# IPK uses underscore `_` in filenames, while APK uses only dash `-`.
|
|
- name: Fix naming difference between build for packages
|
|
if: matrix.package_type == 'ipk'
|
|
shell: bash
|
|
run: |
|
|
for f in ./bin/${{ matrix.package_type }}/*.${{ matrix.package_type }}; do
|
|
[ -e "$f" ] || continue
|
|
base=$(basename "$f")
|
|
newname=$(echo "$base" | sed 's/_/-/g')
|
|
mv "$f" "./bin/${{ matrix.package_type }}/$newname"
|
|
done
|
|
|
|
- name: Filter files
|
|
shell: bash
|
|
run: |
|
|
VERSION="${{ needs.preparation.outputs.version }}"
|
|
|
|
mkdir -p ./filtered-bin/${{ matrix.package_type }}
|
|
cp ./bin/${{ matrix.package_type }}/luci-i18n-podkop-plus-ru-*.${{ matrix.package_type }} "./filtered-bin/${{ matrix.package_type }}/luci-i18n-podkop-plus-ru-${VERSION}.${{ matrix.package_type }}"
|
|
cp ./bin/${{ matrix.package_type }}/podkop-plus-*.${{ matrix.package_type }} ./filtered-bin/${{ matrix.package_type }}/
|
|
cp ./bin/${{ matrix.package_type }}/luci-app-podkop-plus-*.${{ matrix.package_type }} ./filtered-bin/${{ matrix.package_type }}/
|
|
|
|
- name: Remove Docker container
|
|
run: docker rm ${{ matrix.package_type }}
|
|
|
|
- name: Upload build artifacts
|
|
uses: actions/upload-artifact@v4.6.2
|
|
with:
|
|
name: release-files-${{ needs.preparation.outputs.version }}-${{ matrix.package_type }}
|
|
path: ./filtered-bin/${{ matrix.package_type }}/*.${{ matrix.package_type }}
|
|
retention-days: 1
|
|
if-no-files-found: error
|
|
|
|
release:
|
|
name: Create Release
|
|
runs-on: ubuntu-latest
|
|
needs:
|
|
- preparation
|
|
- build
|
|
steps:
|
|
- uses: actions/checkout@v5.0.0
|
|
- name: Create release dir
|
|
run: mkdir -p ./filtered-bin/release
|
|
|
|
- name: Download ipk artifacts
|
|
uses: actions/download-artifact@v4
|
|
with:
|
|
name: release-files-${{ needs.preparation.outputs.version }}-ipk
|
|
path: ./filtered-bin/release
|
|
|
|
- name: Download apk artifacts
|
|
uses: actions/download-artifact@v4
|
|
with:
|
|
name: release-files-${{ needs.preparation.outputs.version }}-apk
|
|
path: ./filtered-bin/release
|
|
|
|
- name: Release
|
|
uses: softprops/action-gh-release@v2.4.0
|
|
with:
|
|
files: ./filtered-bin/release/*.*
|
|
draft: false
|
|
prerelease: false
|
|
name: ${{ needs.preparation.outputs.version }}
|
|
tag_name: ${{ needs.preparation.outputs.version }}
|