From f8e83cf87770590acee34784f40e9fa35bf54799 Mon Sep 17 00:00:00 2001 From: Xiaonan Shen Date: Wed, 15 Apr 2020 00:17:01 -0700 Subject: [PATCH] Add GitHub Actions --- .dockerignore | 4 ++- .github/workflows/main.yaml | 52 +++++++++++++++++++++++++++++++++++++ .gitignore | 10 +------ Dockerfile | 11 ++------ entrypoint.sh | 2 +- install.sh | 13 +++++++--- releaserc | 2 ++ repack-deb.sh | 25 ++++++++++++++++++ setup.sh | 24 ----------------- 9 files changed, 96 insertions(+), 47 deletions(-) create mode 100644 .github/workflows/main.yaml create mode 100644 releaserc create mode 100644 repack-deb.sh delete mode 100644 setup.sh diff --git a/.dockerignore b/.dockerignore index 12730ae..54a69f3 100644 --- a/.dockerignore +++ b/.dockerignore @@ -1,6 +1,8 @@ * !.dockerignore -!*.sh +!releaserc +!entrypoint.sh +!install.sh !gpgparams !Dockerfile diff --git a/.github/workflows/main.yaml b/.github/workflows/main.yaml new file mode 100644 index 0000000..adac411 --- /dev/null +++ b/.github/workflows/main.yaml @@ -0,0 +1,52 @@ +on: + push: + tags: + - '*' + +env: + DOCKER_TAG: shenxn/protonmail-bridge + +jobs: + build: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@master + - name: Set Env + run: | + source releaserc + echo "::set-env name=RELEASE::${RELEASE}" + echo "::set-env name=DEB_FILE::${DEB_FILE}" + - name: Repack deb + run: bash repack-deb.sh + - name: Create Release + id: create-release + uses: actions/create-release@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + tag_name: ${{ env.RELEASE }} + release_name: Release ${{ env.RELEASE }} + body: Repacked ProtonMail Bridge deb without dependencies not needed by cli mode. + draft: false + prerelease: false + - name: Upload Release Asset + id: upload-release-asset + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + upload_url: ${{ steps.create-release.outputs.upload_url }} + asset_path: ./deb/${{ env.DEB_FILE }} + asset_name: ${{ env.DEB_FILE }} + asset_content_type: application/vnd.debian.binary-package + - name: Docker Login + uses: azure/docker-login@v1 + with: + username: ${{ secrets.REGISTRY_USERNAME }} + password: ${{ secrets.REGISTRY_PASSWORD }} + - name: Docker Build + run: | + docker build . -t ${DOCKER_TAG}:latest -t ${DOCKER_TAG}:${RELEASE} + docker push ${DOCKER_TAG}:latest + docker push ${DOCKER_TAG}:${RELEASE} diff --git a/.gitignore b/.gitignore index 6a63f0a..e619f9c 100644 --- a/.gitignore +++ b/.gitignore @@ -1,9 +1 @@ -* - -!.gitignore -!.dockerignore -!LICENSE -!README.md -!*.sh -!gpgparams -!Dockerfile +deb diff --git a/Dockerfile b/Dockerfile index ed56227..6d41bfd 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,18 +1,11 @@ -FROM debian:buster-slim AS setup - -COPY setup.sh /bin/ -RUN bash /bin/setup.sh - - FROM debian:buster-slim LABEL maintainer="Xiaonan Shen " EXPOSE 25/tcp EXPOSE 143/tcp -# Copy gpg parameters and .deb installer -COPY gpgparams install.sh entrypoint.sh /protonmail/ -COPY --from=setup /protonmail/protonmail.deb /protonmail/ +# Copy bash scripts +COPY gpgparams install.sh entrypoint.sh releaserc /protonmail/ # Install dependencies and protonmail bridge RUN bash /protonmail/install.sh diff --git a/entrypoint.sh b/entrypoint.sh index 119186f..13637e5 100644 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -1,6 +1,6 @@ #!/bin/bash -set -e +set -ex # Initialize if [[ $1 == init ]]; then diff --git a/install.sh b/install.sh index c008769..229782f 100644 --- a/install.sh +++ b/install.sh @@ -1,11 +1,18 @@ #!/bin/bash -set -x +set -ex + +source /protonmail/releaserc # Install dependents -# libgl1-mesa-glx is installed since the bridge requires libgl and we removed the qt dependencies apt-get update -apt-get install -y --no-install-recommends socat pass libgl1-mesa-glx +apt-get install -y --no-install-recommends socat pass + +# Download repacked deb +apt-get install -y wget +wget -O /protonmail/protonmail.deb https://github.com/shenxn/protonmail-bridge-docker/releases/download/${RELEASE}/${DEB_FILE} +apt-get purge -y wget +apt-get autoremove -y # Install protonmail bridge apt-get install -y --no-install-recommends /protonmail/protonmail.deb diff --git a/releaserc b/releaserc new file mode 100644 index 0000000..71811ba --- /dev/null +++ b/releaserc @@ -0,0 +1,2 @@ +RELEASE=1.2.6-1 +DEB_FILE=protonmail-bridge_${RELEASE}_amd64.deb diff --git a/repack-deb.sh b/repack-deb.sh new file mode 100644 index 0000000..eecde52 --- /dev/null +++ b/repack-deb.sh @@ -0,0 +1,25 @@ +#!/bin/bash + +set -ex + +source releaserc + +# Download deb +mkdir deb +cd deb +rm -f ${DEB_FILE} +wget https://protonmail.com/download/${DEB_FILE} + +# Unpack deb +ar x -v ${DEB_FILE} +mkdir control +tar xvfJ control.tar.xz -C control + +# Replace qt with libgl and remove unnecessary dependencies +sed -i "s/^Depends: .*$/Depends: libsecret-1-0, libgl1-mesa-glx/" control/control + +# Pack deb +cd control +tar cvfJ ../control.tar.xz . +cd ../ +ar rcs -v ${DEB_FILE} debian-binary control.tar.xz data.tar.xz diff --git a/setup.sh b/setup.sh deleted file mode 100644 index 635e54f..0000000 --- a/setup.sh +++ /dev/null @@ -1,24 +0,0 @@ -#!/bin/bash - -set -x - -DEB_URL=https://protonmail.com/download/protonmail-bridge_1.2.6-1_amd64.deb - -# Install tools -apt-get update -apt-get install -y wget binutils xz-utils - -# Download deb -mkdir /protonmail -cd /protonmail -wget -O /protonmail/protonmail.deb ${DEB_URL} - -# Remove unnecessary dependencies -ar x -v protonmail.deb -mkdir control -tar xvfJ control.tar.xz -C control -cd control -sed -i "s/^Depends: .*$/Depends: libsecret-1-0/" control -tar cvfJ ../control.tar.xz . -cd ../ -ar rcs -v protonmail.deb debian-binary control.tar.xz data.tar.xz