Skip to content

.github/workflows/push-docker-image-manual.yml added params #35

.github/workflows/push-docker-image-manual.yml added params

.github/workflows/push-docker-image-manual.yml added params #35

Workflow file for this run

name: release
on:
push:
tags:
- 'v*' # Push events to matching v*, i.e. v1.0, v20.15.10
env:
REGISTRY: docker.io
permissions: write-all
jobs:
create_release:
name: create release
runs-on: ubuntu-latest
outputs:
upload_url: ${{ steps.create_release.outputs.upload_url }}
steps:
- name: create release
id: create_release
uses: actions/create-release@v1
env:
# for triggering workflow "push-docker-image-release" - https://docs.github.com/en/actions/using-workflows/triggering-a-workflow#triggering-a-workflow-from-a-workflow
GITHUB_TOKEN: ${{ secrets.ANYTYPE_PAT }}
with:
tag_name: ${{ github.ref }}
release_name: Release ${{ github.ref }}
draft: false
prerelease: false
build:
name: build release
runs-on: ubuntu-latest
needs: create_release
strategy:
matrix:
arch:
- amd64
- arm64
os:
- linux
image_name:
#- centos:7 # not supported, need python >=3.8
- almalinux:9
- ubuntu:22.04
include:
- arch: amd64
rpm_arch: x86_64
deb_arch: amd64
- arch: arm64
rpm_arch: aarch64
deb_arch: arm64
steps:
- name: Checkout Github code
uses: actions/checkout@v3
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
with:
platforms: ${{ matrix.arch }}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
with:
install: true
- name: get release version
id: release-version
run: |
echo "$GITHUB_REF_NAME" | sed 's|^[a-zA-Z]\+||; s|-[0-9]\+$||; s|^|RELEASE_VERSION=|' >> $GITHUB_OUTPUT
- name: get os_release info
id: release_info
run: |
case ${{ matrix.image_name }} in
centos:7)
INSTALL_REQUIRED_PACKAGES_CMD="yum update -y && yum install -y python3 python3-devel perl rsync && yum groupinstall -y 'Development Tools'"
FPM_OUTPUT_TYPE=rpm
FPM_ARCH=${{ matrix.rpm_arch }}
FPM_OPTIONS="--rpm-dist el7"
;;
almalinux:9)
INSTALL_REQUIRED_PACKAGES_CMD="yum update -y && yum install -y python3 python3-devel perl rsync && yum groupinstall -y 'Development Tools'"
FPM_OUTPUT_TYPE=rpm
FPM_ARCH=${{ matrix.rpm_arch }}
FPM_OPTIONS="--rpm-dist el9"
;;
ubuntu:22.04)
INSTALL_REQUIRED_PACKAGES_CMD="apt-get update && apt install -y python3 python3-dev python3-venv perl rsync build-essential"
FPM_OUTPUT_TYPE=deb
FPM_ARCH=${{ matrix.deb_arch }}
FPM_OPTIONS=""
;;
*)
echo "ERROR: unsupported matrix.image_name=${{ matrix.image_name }}" 1>&2
exit 1
;;
esac
echo "INSTALL_REQUIRED_PACKAGES_CMD=$INSTALL_REQUIRED_PACKAGES_CMD" >> $GITHUB_OUTPUT
echo "FPM_OUTPUT_TYPE=$FPM_OUTPUT_TYPE" >> $GITHUB_OUTPUT
echo "FPM_ARCH=$FPM_ARCH" >> $GITHUB_OUTPUT
echo "FPM_OPTIONS=$FPM_OPTIONS" >> $GITHUB_OUTPUT
- name: debug show GITHUB_OUTPUT
run: echo ${{ steps.release_info.outputs }}
# build {{
- name: build on ${{ matrix.image_name }}
if: matrix.os == 'linux'
run: |
docker run --platform ${{ matrix.arch }} --rm --volume ${{ github.workspace }}:/workspace --workdir /workspace ${{ matrix.image_name }} /bin/bash -c \
"
${{ steps.release_info.outputs.INSTALL_REQUIRED_PACKAGES_CMD }}
./build.sh
"
# }}
# create asset {{
- name: create package ${{ steps.release_info.outputs.FPM_ARCH }}
if: matrix.os == 'linux'
uses: fb929/github-action-fpm@master
with:
fpm_opts:
--name ${{ github.event.repository.name }}
--version ${{ steps.release-version.outputs.RELEASE_VERSION }}
--architecture ${{ steps.release_info.outputs.FPM_ARCH }}
--exclude '*/.gitignore'
--exclude '*/.git'
--input-type dir
--chdir ./build
--output-type ${{ steps.release_info.outputs.FPM_OUTPUT_TYPE }}
${{ steps.release_info.outputs.FPM_OPTIONS }}
fpm_args: ./
# }}
- name: debug ls
run: ls -al ./
#- name: debug find
# run: find ./ -type f
# upload-release-asset {{
- name: Upload Release Asset
run: |
UPLOAD_URL=$( echo "${{ needs.create_release.outputs.upload_url }}" | sed 's|{?name,label}||' )
FILES=$( ls ./*.${{ steps.release_info.outputs.FPM_OUTPUT_TYPE }} )
echo "UPLOAD_URL=$UPLOAD_URL"
echo "FILES=$FILES"
for FILE in $FILES; do
echo "uploading $FILE"
curl \
-X POST \
-H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
-H "Content-Type: application/octet-stream" \
--data-binary @${FILE} \
"${UPLOAD_URL}?name=$(basename $FILE)"
done
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# }}