mirror of
https://github.com/shenxn/protonmail-bridge-docker.git
synced 2025-12-06 08:27:08 +00:00
improve build readability and speed
This commit is contained in:
parent
540ba69528
commit
db5aa2dc8d
214
.github/workflows/build.yaml
vendored
214
.github/workflows/build.yaml
vendored
@ -2,94 +2,212 @@ name: build from source
|
|||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
branches:
|
|
||||||
- master
|
|
||||||
- dev
|
|
||||||
paths:
|
paths:
|
||||||
- .github/workflows/build.yaml
|
- .github/workflows/build.yaml
|
||||||
- build/*
|
- build/*
|
||||||
- deb/*
|
- VERSION
|
||||||
pull_request:
|
pull_request:
|
||||||
paths:
|
paths:
|
||||||
- .github/workflows/build.yaml
|
- .github/workflows/build.yaml
|
||||||
- build/*
|
- build/*
|
||||||
- deb/*
|
|
||||||
workflow_dispatch:
|
workflow_dispatch:
|
||||||
|
|
||||||
env:
|
env:
|
||||||
DOCKER_REPO: shenxn/protonmail-bridge
|
GHCR_REPO: shenxn/protonmail-bridge-docker
|
||||||
|
DOCKERHUB_REPO: shenxn/protonmail-bridge
|
||||||
DOCKER_REPO_DEV: ghcr.io/shenxn/protonmail-bridge-dev
|
DOCKER_REPO_DEV: ghcr.io/shenxn/protonmail-bridge-dev
|
||||||
PLATFORMS: linux/amd64,linux/arm64/v8,linux/arm/v7,linux/riscv64
|
PLATFORMS: linux/amd64,linux/arm64/v8,linux/arm/v7,linux/riscv64
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build:
|
test:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
services:
|
if: github.event_name == 'pull_request'
|
||||||
registry:
|
|
||||||
image: registry:2
|
|
||||||
ports:
|
|
||||||
- 5000:5000
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Prepare
|
||||||
uses: actions/checkout@master
|
run: |
|
||||||
|
platform=${{ matrix.platform }}
|
||||||
|
echo "PLATFORM_PAIR=${platform//\//-}" >> $GITHUB_ENV
|
||||||
|
|
||||||
- name: Set version
|
- name: Set version
|
||||||
id: version
|
id: version
|
||||||
run: echo "::set-output name=version::`cat build/VERSION`"
|
run: echo "::set-output name=version::`cat VERSION`"
|
||||||
- name: Set repo
|
|
||||||
id: repo
|
|
||||||
run: if [[ $GITHUB_REF == "refs/heads/master" ]]; then echo "::set-output name=repo::${DOCKER_REPO}"; else echo "::set-output name=repo::${DOCKER_REPO_DEV}"; fi
|
|
||||||
- name: Docker meta
|
- name: Docker meta
|
||||||
id: docker_meta
|
id: meta
|
||||||
uses: crazy-max/ghaction-docker-meta@v1
|
uses: docker/metadata-action@v5
|
||||||
with:
|
with:
|
||||||
images: ${{ steps.repo.outputs.repo }}
|
images: |
|
||||||
- name: Set up QEMU
|
${{ env.DOCKERHUB_REPO }}
|
||||||
uses: docker/setup-qemu-action@v1
|
${{ env.GHCR_REPO }}
|
||||||
|
|
||||||
- name: Set up Docker Buildx
|
- name: Set up Docker Buildx
|
||||||
uses: docker/setup-buildx-action@v1
|
uses: docker/setup-buildx-action@v3
|
||||||
with:
|
with:
|
||||||
driver-opts: network=host
|
driver-opts: network=host
|
||||||
- name: Build image without push to registry
|
|
||||||
uses: docker/build-push-action@v2
|
- name: Build and push by digest
|
||||||
|
id: build
|
||||||
|
uses: docker/build-push-action@v6
|
||||||
with:
|
with:
|
||||||
|
labels: ${{ steps.meta.outputs.labels }}
|
||||||
|
outputs: type=image,"name=${{ env.DOCKERHUB_REPO }},${{ env.GHCR_REPO }}",push-by-digest=true,name-canonical=true,push=false
|
||||||
context: ./build
|
context: ./build
|
||||||
file: ./build/Dockerfile
|
file: ./build/Dockerfile
|
||||||
platforms: ${{ env.PLATFORMS }}
|
tags: localbuild/protonmail-bridge:test
|
||||||
push: true
|
build-args: |
|
||||||
tags: localhost:5000/protonmail-bridge:latest
|
version="${{ steps.version.outputs.version }}"
|
||||||
- name: Scan image
|
- name: Scan image
|
||||||
id: scan
|
id: scan
|
||||||
uses: anchore/scan-action@v2
|
uses: anchore/scan-action@v6
|
||||||
with:
|
with:
|
||||||
image: localhost:5000/protonmail-bridge:latest
|
image: localbuild/protonmail-bridge:test
|
||||||
fail-build: true
|
fail-build: true
|
||||||
severity-cutoff: critical
|
severity-cutoff: critical
|
||||||
acs-report-enable: true
|
|
||||||
- name: Upload Anchore scan SARIF report
|
- name: Upload Anchore scan SARIF report
|
||||||
uses: github/codeql-action/upload-sarif@v1
|
uses: github/codeql-action/upload-sarif@v3
|
||||||
with:
|
with:
|
||||||
sarif_file: ${{ steps.scan.outputs.sarif }}
|
sarif_file: ${{ steps.scan.outputs.sarif }}
|
||||||
- name: Login to DockerHub
|
|
||||||
uses: docker/login-action@v1
|
build:
|
||||||
if: ${{ github.event_name != 'pull_request' && github.ref == 'refs/heads/master' }}
|
runs-on: ubuntu-latest
|
||||||
|
if: github.event_name == 'push' && github.ref == 'refs/heads/master'
|
||||||
|
strategy:
|
||||||
|
fail-fast: false
|
||||||
|
matrix:
|
||||||
|
platform:
|
||||||
|
- linux/amd64
|
||||||
|
- linux/arm64/v8
|
||||||
|
- linux/arm/v7
|
||||||
|
- linux/riscv64
|
||||||
|
steps:
|
||||||
|
- name: Prepare
|
||||||
|
run: |
|
||||||
|
platform=${{ matrix.platform }}
|
||||||
|
echo "PLATFORM_PAIR=${platform//\//-}" >> $GITHUB_ENV
|
||||||
|
|
||||||
|
- name: Set version
|
||||||
|
id: version
|
||||||
|
run: echo "::set-output name=version::`cat VERSION`"
|
||||||
|
|
||||||
|
- name: Docker meta
|
||||||
|
id: meta
|
||||||
|
uses: docker/metadata-action@v5
|
||||||
|
with:
|
||||||
|
images: |
|
||||||
|
${{ env.DOCKERHUB_REPO }}
|
||||||
|
${{ env.GHCR_REPO }}
|
||||||
|
|
||||||
|
- name: Login to Docker Hub
|
||||||
|
uses: docker/login-action@v3
|
||||||
|
with:
|
||||||
|
username: ${{ vars.DOCKERHUB_USERNAME }}
|
||||||
|
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
||||||
|
|
||||||
|
- name: Login to GHCR
|
||||||
|
uses: docker/login-action@v3
|
||||||
|
with:
|
||||||
|
registry: ghcr.io
|
||||||
|
username: ${{ github.repository_owner }}
|
||||||
|
password: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
|
||||||
|
- name: Set up QEMU
|
||||||
|
uses: docker/setup-qemu-action@v3
|
||||||
|
|
||||||
|
- name: Set up Docker Buildx
|
||||||
|
uses: docker/setup-buildx-action@v3
|
||||||
|
|
||||||
|
- name: Build and push by digest
|
||||||
|
id: build
|
||||||
|
uses: docker/build-push-action@v6
|
||||||
|
with:
|
||||||
|
platforms: ${{ matrix.platform }}
|
||||||
|
labels: ${{ steps.meta.outputs.labels }}
|
||||||
|
outputs: type=image,"name=name=${{ env.DOCKERHUB_REPO }},${{ env.GHCR_REPO }}",push-by-digest=true,name-canonical=true,push=true
|
||||||
|
context: ./build
|
||||||
|
file: ./build/Dockerfile
|
||||||
|
tags: build,{{ steps.version.outputs.version }}-build
|
||||||
|
provenance: true
|
||||||
|
sbom: true
|
||||||
|
build-args: |
|
||||||
|
version="${{ steps.version.outputs.version }}"
|
||||||
|
|
||||||
|
- name: Export digest
|
||||||
|
run: |
|
||||||
|
mkdir -p ${{ runner.temp }}/digests
|
||||||
|
digest="${{ steps.build.outputs.digest }}"
|
||||||
|
touch "${{ runner.temp }}/digests/${digest#sha256:}"
|
||||||
|
|
||||||
|
- name: Scan image
|
||||||
|
id: scan
|
||||||
|
uses: anchore/scan-action@v6
|
||||||
|
with:
|
||||||
|
image: ${{ env.DOCKERHUB_REPO }}/protonmail-bridge:${{ steps.build.outputs.digest }}
|
||||||
|
fail-build: true
|
||||||
|
severity-cutoff: critical
|
||||||
|
- name: Upload Anchore scan SARIF report
|
||||||
|
uses: github/codeql-action/upload-sarif@v3
|
||||||
|
with:
|
||||||
|
sarif_file: ${{ steps.scan.outputs.sarif }}
|
||||||
|
|
||||||
|
- name: Upload digest
|
||||||
|
uses: actions/upload-artifact@v4
|
||||||
|
with:
|
||||||
|
name: digests-${{ env.PLATFORM_PAIR }}
|
||||||
|
path: ${{ runner.temp }}/digests/*
|
||||||
|
if-no-files-found: error
|
||||||
|
retention-days: 1
|
||||||
|
|
||||||
|
|
||||||
|
merge:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
needs:
|
||||||
|
- build
|
||||||
|
steps:
|
||||||
|
- name: Download digests
|
||||||
|
uses: actions/download-artifact@v4
|
||||||
|
with:
|
||||||
|
path: ${{ runner.temp }}/digests
|
||||||
|
pattern: digests-*
|
||||||
|
merge-multiple: true
|
||||||
|
|
||||||
|
- name: Login to Docker Hub
|
||||||
|
uses: docker/login-action@v3
|
||||||
with:
|
with:
|
||||||
username: ${{ secrets.REGISTRY_USERNAME }}
|
username: ${{ secrets.REGISTRY_USERNAME }}
|
||||||
password: ${{ secrets.REGISTRY_PASSWORD }}
|
password: ${{ secrets.REGISTRY_PASSWORD }}
|
||||||
- name: Login to GitHub Container Registry
|
|
||||||
uses: docker/login-action@v1
|
- name: Login to GHCR
|
||||||
if: ${{ github.event_name != 'pull_request' && github.ref == 'refs/heads/dev' }}
|
uses: docker/login-action@v3
|
||||||
with:
|
with:
|
||||||
registry: ghcr.io
|
registry: ghcr.io
|
||||||
username: ${{ github.repository_owner }}
|
username: ${{ github.repository_owner }}
|
||||||
password: ${{ secrets.CR_PAT }}
|
password: ${{ secrets.CR_PAT }}
|
||||||
- name: Push image
|
|
||||||
uses: docker/build-push-action@v2
|
- name: Set up Docker Buildx
|
||||||
|
uses: docker/setup-buildx-action@v3
|
||||||
with:
|
with:
|
||||||
context: ./build
|
driver-opts: network=host
|
||||||
file: ./build/Dockerfile
|
|
||||||
platforms: ${{ env.PLATFORMS }}
|
- name: Docker meta
|
||||||
|
id: meta
|
||||||
|
uses: docker/metadata-action@v5
|
||||||
|
with:
|
||||||
|
images: |
|
||||||
|
${{ env.DOCKERHUB_REPO }}
|
||||||
|
${{ env.GHCR_REPO }}
|
||||||
tags: |
|
tags: |
|
||||||
${{ steps.repo.outputs.repo }}:build
|
type=raw,enable=true,value=${{ steps.version.outputs.version }}-build
|
||||||
${{ steps.repo.outputs.repo }}:${{ steps.version.outputs.version }}-build
|
type=raw,enable=true,suffix=,value=build
|
||||||
labels: ${{ steps.docker_meta.outputs.labels }}
|
|
||||||
push: ${{ github.event_name != 'pull_request' }}
|
- name: Create manifest list and push
|
||||||
|
working-directory: ${{ runner.temp }}/digests
|
||||||
|
run: |
|
||||||
|
docker buildx imagetools create $(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \
|
||||||
|
$(printf '${{ env.DOCKERHUB_REPO }}@sha256:%s ' *)
|
||||||
|
docker buildx imagetools create $(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \
|
||||||
|
$(printf '${{ env.GHCR_REPO }}@sha256:%s ' *)
|
||||||
|
|
||||||
|
- name: Inspect image
|
||||||
|
run: |
|
||||||
|
docker buildx imagetools inspect ${{ env.DOCKERHUB_REPO }}:${{ steps.meta.outputs.version }}
|
||||||
|
docker buildx imagetools inspect ${{ env.GHCR_REPO }}:${{ steps.meta.outputs.version }}
|
||||||
|
|||||||
6
.github/workflows/deb.yaml
vendored
6
.github/workflows/deb.yaml
vendored
@ -25,7 +25,7 @@ jobs:
|
|||||||
uses: actions/checkout@master
|
uses: actions/checkout@master
|
||||||
- name: Set version
|
- name: Set version
|
||||||
id: version
|
id: version
|
||||||
run: echo "::set-output name=version::`cat deb/VERSION`"
|
run: echo "::set-output name=version::`cat VERSION`"
|
||||||
- name: Set repo
|
- name: Set repo
|
||||||
id: repo
|
id: repo
|
||||||
run: if [[ $GITHUB_REF == "refs/heads/master" ]]; then echo "::set-output name=repo::${DOCKER_REPO}"; else echo "::set-output name=repo::${DOCKER_REPO_DEV}"; fi
|
run: if [[ $GITHUB_REF == "refs/heads/master" ]]; then echo "::set-output name=repo::${DOCKER_REPO}"; else echo "::set-output name=repo::${DOCKER_REPO_DEV}"; fi
|
||||||
@ -57,13 +57,13 @@ jobs:
|
|||||||
sarif_file: ${{ steps.scan.outputs.sarif }}
|
sarif_file: ${{ steps.scan.outputs.sarif }}
|
||||||
- name: Login to DockerHub
|
- name: Login to DockerHub
|
||||||
uses: docker/login-action@v1
|
uses: docker/login-action@v1
|
||||||
if: ${{ github.event_name != 'pull_request' && github.ref == 'refs/heads/master' }}
|
if: ${{ github.event_name != 'pull_request' }}
|
||||||
with:
|
with:
|
||||||
username: ${{ secrets.REGISTRY_USERNAME }}
|
username: ${{ secrets.REGISTRY_USERNAME }}
|
||||||
password: ${{ secrets.REGISTRY_PASSWORD }}
|
password: ${{ secrets.REGISTRY_PASSWORD }}
|
||||||
- name: Login to GitHub Container Registry
|
- name: Login to GitHub Container Registry
|
||||||
uses: docker/login-action@v1
|
uses: docker/login-action@v1
|
||||||
if: ${{ github.event_name != 'pull_request' && github.ref == 'refs/heads/dev' }}
|
if: ${{ github.event_name != 'pull_request' }}
|
||||||
with:
|
with:
|
||||||
registry: ghcr.io
|
registry: ghcr.io
|
||||||
username: ${{ github.repository_owner }}
|
username: ${{ github.repository_owner }}
|
||||||
|
|||||||
@ -2,12 +2,12 @@
|
|||||||
FROM debian:sid-slim AS build
|
FROM debian:sid-slim AS build
|
||||||
|
|
||||||
# Install dependencies
|
# Install dependencies
|
||||||
RUN apt-get update && apt-get install -y git golang build-essential libsecret-1-dev
|
RUN apt-get update && apt-get install -y golang build-essential libsecret-1-dev
|
||||||
|
|
||||||
# Build
|
# Build
|
||||||
|
ADD https://github.com/ProtonMail/proton-bridge.git#{version} /build/
|
||||||
WORKDIR /build/
|
WORKDIR /build/
|
||||||
COPY build.sh VERSION /build/
|
RUN make build-nogui vault-editor
|
||||||
RUN bash build.sh
|
|
||||||
|
|
||||||
FROM debian:sid-slim
|
FROM debian:sid-slim
|
||||||
LABEL maintainer="Simon Felding <sife@adm.ku.dk>"
|
LABEL maintainer="Simon Felding <sife@adm.ku.dk>"
|
||||||
@ -24,8 +24,8 @@ RUN apt-get update \
|
|||||||
COPY gpgparams entrypoint.sh /protonmail/
|
COPY gpgparams entrypoint.sh /protonmail/
|
||||||
|
|
||||||
# Copy protonmail
|
# Copy protonmail
|
||||||
COPY --from=build /build/proton-bridge/bridge /protonmail/
|
COPY --from=build /build/bridge /protonmail/
|
||||||
COPY --from=build /build/proton-bridge/proton-bridge /protonmail/
|
COPY --from=build /build/proton-bridge /protonmail/
|
||||||
COPY --from=build /build/proton-bridge/vault-editor /protonmail/
|
COPY --from=build /build/vault-editor /protonmail/
|
||||||
|
|
||||||
ENTRYPOINT ["bash", "/protonmail/entrypoint.sh"]
|
ENTRYPOINT ["bash", "/protonmail/entrypoint.sh"]
|
||||||
|
|||||||
@ -1 +0,0 @@
|
|||||||
3.19.0
|
|
||||||
@ -1,13 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
|
|
||||||
set -ex
|
|
||||||
|
|
||||||
VERSION=`cat VERSION`
|
|
||||||
|
|
||||||
# Clone new code
|
|
||||||
git clone https://github.com/ProtonMail/proton-bridge.git
|
|
||||||
cd proton-bridge
|
|
||||||
git checkout v$VERSION
|
|
||||||
|
|
||||||
# Build
|
|
||||||
make build-nogui vault-editor
|
|
||||||
@ -1,5 +1,16 @@
|
|||||||
|
### The Deb install is just a repack of the official ProtonMail Bridge deb package with less dependencies.
|
||||||
|
### I recommend you don't use this. It's here for legacy reasons.
|
||||||
|
|
||||||
|
FROM debian:sid-slim as build
|
||||||
|
|
||||||
|
COPY RELEASE install.sh /
|
||||||
|
RUN apt-get update && apt-get install -y wget binutils
|
||||||
|
|
||||||
|
# Repack deb (removes unnecessary dependencies and produces /protonmail.deb)
|
||||||
|
RUN bash /install.sh
|
||||||
|
|
||||||
FROM debian:sid-slim
|
FROM debian:sid-slim
|
||||||
LABEL maintainer="Xiaonan Shen <s@sxn.dev>"
|
LABEL maintainer="Simon Felding <sife@adm.ku.dk>"
|
||||||
|
|
||||||
EXPOSE 25/tcp
|
EXPOSE 25/tcp
|
||||||
EXPOSE 143/tcp
|
EXPOSE 143/tcp
|
||||||
@ -7,16 +18,11 @@ EXPOSE 143/tcp
|
|||||||
WORKDIR /protonmail
|
WORKDIR /protonmail
|
||||||
|
|
||||||
# Copy bash scripts
|
# Copy bash scripts
|
||||||
COPY gpgparams install.sh entrypoint.sh VERSION /protonmail/
|
COPY gpgparams entrypoint.sh RELEASE /protonmail/
|
||||||
|
COPY --from=build /protonmail.deb /tmp/protonmail.deb
|
||||||
|
|
||||||
RUN apt-get update \
|
RUN apt-get update \
|
||||||
&& apt-get install -y --no-install-recommends socat pass procps libsecret-1-0 ca-certificates \
|
&& apt-get install -y --no-install-recommends /tmp/protonmail.deb socat pass libsecret-1-0 ca-certificates \
|
||||||
&& rm -rf /var/lib/apt/lists/*
|
&& rm -rf /var/lib/apt/lists/*
|
||||||
|
|
||||||
# Copy bash scripts
|
CMD ["bash", "/protonmail/entrypoint.sh"]
|
||||||
COPY gpgparams entrypoint.sh /protonmail/
|
|
||||||
|
|
||||||
# Install dependencies and protonmail bridge
|
|
||||||
RUN bash install.sh
|
|
||||||
|
|
||||||
ENTRYPOINT ["bash", "/protonmail/entrypoint.sh"]
|
|
||||||
|
|||||||
1
deb/PACKAGE
Normal file
1
deb/PACKAGE
Normal file
@ -0,0 +1 @@
|
|||||||
|
https://github.com/ProtonMail/proton-bridge/releases/download/v3.16.0/protonmail-bridge_3.16.0-1_amd64.deb
|
||||||
@ -1 +0,0 @@
|
|||||||
3.19.0-1
|
|
||||||
@ -1,36 +1,16 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
set -ex
|
set -ex
|
||||||
|
|
||||||
VERSION=`cat VERSION`
|
|
||||||
DEB_FILE=protonmail-bridge_${VERSION}_amd64.deb
|
|
||||||
|
|
||||||
# Install dependents
|
|
||||||
apt-get update
|
|
||||||
apt-get install -y --no-install-recommends socat pass ca-certificates
|
|
||||||
|
|
||||||
# Build time dependencies
|
|
||||||
apt-get install -y wget binutils xz-utils
|
|
||||||
|
|
||||||
# Repack deb (remove unnecessary dependencies)
|
# Repack deb (remove unnecessary dependencies)
|
||||||
mkdir deb
|
mkdir deb
|
||||||
|
wget -i "$RELEASE" -O /deb/protonmail.deb
|
||||||
cd deb
|
cd deb
|
||||||
wget -q https://protonmail.com/download/bridge/${DEB_FILE}
|
ar x -v protonmail.deb
|
||||||
ar x -v ${DEB_FILE}
|
|
||||||
mkdir control
|
mkdir control
|
||||||
tar zxvf control.tar.gz -C control
|
tar zxvf control.tar.gz -C control
|
||||||
sed -i "s/^Depends: .*$/Depends: libgl1, libc6, libsecret-1-0, libstdc++6, libgcc1/" control/control
|
sed -i "s/^Depends: .*$/Depends: libgl1, libc6, libsecret-1-0, libstdc++6, libgcc1/" control/control
|
||||||
cd control
|
cd control
|
||||||
tar zcvf ../control.tar.gz .
|
tar zcvf ../control.tar.gz .
|
||||||
cd ../
|
cd ../
|
||||||
ar rcs -v ${DEB_FILE} debian-binary control.tar.gz data.tar.gz
|
|
||||||
cd ../
|
|
||||||
|
|
||||||
# Install protonmail bridge
|
ar rcs -v /protonmail.deb debian-binary control.tar.gz data.tar.gz
|
||||||
apt-get install -y --no-install-recommends ./deb/${DEB_FILE}
|
|
||||||
|
|
||||||
# Cleanup
|
|
||||||
apt-get purge -y wget binutils xz-utils
|
|
||||||
apt-get autoremove -y
|
|
||||||
rm -rf /var/lib/apt/lists/*
|
|
||||||
rm -rf deb
|
|
||||||
|
|||||||
@ -1,64 +1,31 @@
|
|||||||
import sys
|
import requests, os
|
||||||
import os
|
|
||||||
import requests
|
|
||||||
import json
|
|
||||||
import re
|
|
||||||
|
|
||||||
is_pull_request = sys.argv[1] == "true"
|
def git(command):
|
||||||
print(f"is_pull_request={is_pull_request}")
|
return os.system(f"git {command}")
|
||||||
|
|
||||||
|
release = requests.get("https://api.github.com/repos/protonmail/proton-bridge/releases/latest").json()
|
||||||
|
version = release['tag_name']
|
||||||
|
deb = [asset for asset in release ['assets'] if asset['name'].endswith('.deb')][0]['browser_download_url']
|
||||||
|
|
||||||
def check_version(directory, new_version):
|
print(f"Latest release is: {version}")
|
||||||
print(f"Checking version for {directory}")
|
|
||||||
|
|
||||||
if not new_version:
|
with open("VERSION", 'w') as f:
|
||||||
print("Failed to get new version. Exiting.")
|
f.write(version)
|
||||||
exit(1)
|
|
||||||
|
|
||||||
with open(f"{directory}/VERSION", "r") as f:
|
with open("deb/PACKAGE", 'w') as f:
|
||||||
old_version = f.read().rstrip()
|
f.write(deb)
|
||||||
|
|
||||||
print(f"Up-to-date version {new_version}")
|
git("config --local user.name 'GitHub Actions'")
|
||||||
print(f"Current version: {old_version}")
|
git("config --local user.email 'actions@github.com'")
|
||||||
|
|
||||||
if old_version != new_version:
|
git("add -A")
|
||||||
print(f"New release found: {new_version}")
|
|
||||||
|
|
||||||
# bump up to new release
|
if git("diff --cached --quiet") == 0: # Returns 0 if there are no changes
|
||||||
with open(f"{directory}/VERSION", "w") as f:
|
print("Version didn't change")
|
||||||
f.write(new_version)
|
exit(1)
|
||||||
# commit
|
|
||||||
result = os.system(f"git config --local user.email 'actions@github.com' \
|
|
||||||
&& git config --local user.name 'GitHub Actions' \
|
|
||||||
&& git add {directory}/VERSION \
|
|
||||||
&& git commit -m 'Bump {directory} version to {new_version}'")
|
|
||||||
if result != 0:
|
|
||||||
print("Failed to commit the bump. Exiting")
|
|
||||||
exit(1)
|
|
||||||
if is_pull_request:
|
|
||||||
print("Action triggered by pull request. Do not push.")
|
|
||||||
else:
|
|
||||||
result = os.system("git push")
|
|
||||||
if result != 0:
|
|
||||||
print("Failed to push. Exiting")
|
|
||||||
exit(1)
|
|
||||||
else:
|
|
||||||
print(f"Already newest version {old_version}")
|
|
||||||
|
|
||||||
|
git(f"commit -m 'Bump version to {version}'")
|
||||||
|
|
||||||
# check deb version
|
if git("push") != 0:
|
||||||
response = requests.get("https://protonmail.com/download/current_version_linux.json")
|
print("Git push failed!")
|
||||||
content = json.loads(response.content)
|
exit(1)
|
||||||
version = re.match(".*_([0-9.-]+)_amd64\.deb", content["DebFile"]).group(1)
|
|
||||||
check_version("deb", version)
|
|
||||||
|
|
||||||
|
|
||||||
# check build version
|
|
||||||
response = requests.get(
|
|
||||||
"https://api.github.com/repos/ProtonMail/proton-bridge/tags",
|
|
||||||
headers={"Accept": "application/vnd.github.v3+json"},
|
|
||||||
)
|
|
||||||
tags = json.loads(response.content)
|
|
||||||
version_re = re.compile("v\d+\.\d+\.\d+")
|
|
||||||
releases = [tag["name"][1:] for tag in tags if version_re.match(tag["name"])]
|
|
||||||
check_version("build", releases[0])
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user