Skip to content

Commit

Permalink
run github action only on tag and push artifact automatically to tagg…
Browse files Browse the repository at this point in the history
…ed release.
  • Loading branch information
stuartcaunt committed Dec 17, 2024
1 parent 7e2e4d0 commit 6d69d57
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 24 deletions.
16 changes: 5 additions & 11 deletions .github/workflows/build-and-publish-deb.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,8 @@ name: Build and Publish Debian Package

on:
push:
branches:
- feature/package-action
workflow_dispatch:
tags:
- '*'

jobs:
build-debian-package:
Expand All @@ -29,15 +28,11 @@ jobs:
docker build -t webx-engine-builder -f docker/Dockerfile.ubuntu .
- name: Extract Debian package
id: docker_build
run: |
CONTAINER_ID=$(docker create webx-engine-builder)
docker cp $CONTAINER_ID:/app/target/ubuntu/. ./debian-package
docker cp $CONTAINER_ID:/app/VERSION ./debian-package
docker rm -f $CONTAINER_ID
PACKAGE_VERSION=$(cat ./debian-package/VERSION)
mv ./debian-package/webx-engine_${PACKAGE_VERSION}_amd64.deb ./debian-package/webx-engine_${PACKAGE_VERSION}_ubuntu_22.04_amd64.deb
echo "PACKAGE_VERSION=$PACKAGE_VERSION" >> $GITHUB_ENV
mv ./debian-package/webx-engine__amd64.deb ./debian-package/webx-engine_${{ github.ref_name }}_ubuntu_22.04_amd64.deb
- name: Upload Debian package to GHCR
uses: actions/upload-artifact@v3
Expand All @@ -46,11 +41,10 @@ jobs:
path: ./debian-package/

- name: Upload Debian package as Release asset
if: github.event_name == 'workflow_dispatch'
uses: ncipollo/release-action@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
artifacts: debian-package/*.deb
tag: ${{ env.PACKAGE_VERSION }}
tag: ${{ github.ref_name }}
name: "WebX Engine Debian Packages"
body: "Automatically built and uploaded Debian packages for release ${{ env.PACKAGE_VERSION }}."
body: "Automatically built and uploaded Debian packages for release ${{ github.ref_name }}."
1 change: 0 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,6 @@ install(TARGETS ${PROJECT_NAME} DESTINATION "/usr/bin")

SET(CPACK_GENERATOR "DEB")
set(CPACK_CMAKE_GENERATOR Ninja)
set(CPACK_PACKAGE_VERSION "0.1.0")
SET(CPACK_DEBIAN_PACKAGE_MAINTAINER "Stuart Caunt <[email protected]>, Jamie Hall <[email protected]>")
set(CPACK_DEBIAN_PACKAGE_SHLIBDEPS ON)
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "The WebX Engine hooks on to an X11 display and provides a protocol to obtain X11 windows, receive display events and forward mouse and keyboard events.")
Expand Down
4 changes: 0 additions & 4 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,6 @@ RUN cmake .
RUN cmake --build . -j 4 --target webx-engine
RUN cpack -G DEB

# Save the version to a file
RUN awk '/CPACK_PACKAGE_VERSION /{ gsub(/[()]/, " "); gsub(/[\"]/, ""); print $3}' CMakeLists.txt > VERSION

FROM ubuntu:22.04 AS ubuntu

RUN apt update
Expand All @@ -36,7 +33,6 @@ RUN mkdir -p target/debian
RUN mkdir -p target/ubuntu
COPY --from=debian /app/packages/* target/debian
COPY --from=ubuntu /app/packages/* target/ubuntu
COPY --from=debian /app/VERSION .

# to obtain built deb package:
# docker build -t webx-engine-builder .
Expand Down
4 changes: 0 additions & 4 deletions docker/Dockerfile.debian
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,13 @@ RUN cmake .
RUN cmake --build . -j 4 --target webx-engine
RUN cpack -G DEB

# Save the version to a file
RUN awk '/CPACK_PACKAGE_VERSION /{ gsub(/[()]/, " "); gsub(/[\"]/, ""); print $3}' CMakeLists.txt > VERSION

FROM alpine:3

WORKDIR /app

# Copy package to standard directory
RUN mkdir -p target/debian
COPY --from=debian /app/packages/* target/debian
COPY --from=debian /app/VERSION .

# to obtain built deb package:
# docker build -t webx-engine-builder .
Expand Down
4 changes: 0 additions & 4 deletions docker/Dockerfile.ubuntu
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,13 @@ RUN cmake .
RUN cmake --build . -j 4 --target webx-engine
RUN cpack -G DEB

# Save the version to a file
RUN awk '/CPACK_PACKAGE_VERSION /{ gsub(/[()]/, " "); gsub(/[\"]/, ""); print $3}' CMakeLists.txt > VERSION

FROM alpine:3

WORKDIR /app

# Copy package to standard directory
RUN mkdir -p target/ubuntu
COPY --from=ubuntu /app/packages/* target/ubuntu
COPY --from=ubuntu /app/VERSION .

# to obtain built deb package:
# docker build -t webx-engine-builder .
Expand Down

0 comments on commit 6d69d57

Please sign in to comment.