mirror of
https://github.com/yuezk/GlobalProtect-openconnect.git
synced 2026-11-19 22:46:14 -05:00
ci: publish docker images by digest
This commit is contained in:
3 files changed
+211
-4
No files matched your search
@@ -179,6 +179,63 @@ jobs:
|
|||||||
path: |
|
path: |
|
||||||
build-gp-${{ matrix.package }}/artifacts/*
|
build-gp-${{ matrix.package }}/artifacts/*
|
||||||
|
|
||||||
|
build-docker-image:
|
||||||
|
strategy:
|
||||||
|
fail-fast: false
|
||||||
|
matrix:
|
||||||
|
include:
|
||||||
|
- runner: ubuntu-latest
|
||||||
|
platform: linux/amd64
|
||||||
|
- runner: ubuntu-24.04-arm
|
||||||
|
platform: linux/arm64
|
||||||
|
runs-on: ${{ matrix.runner }}
|
||||||
|
steps:
|
||||||
|
- name: Prepare
|
||||||
|
run: |
|
||||||
|
platform=${{ matrix.platform }}
|
||||||
|
echo "PLATFORM_PAIR=${platform//\//-}" >> "$GITHUB_ENV"
|
||||||
|
- name: Checkout GlobalProtect-openconnect
|
||||||
|
uses: actions/checkout@v6
|
||||||
|
with:
|
||||||
|
token: ${{ secrets.GH_PAT }}
|
||||||
|
repository: yuezk/GlobalProtect-openconnect
|
||||||
|
ref: ${{ github.event_name == 'workflow_dispatch' && inputs.gp_branch || github.ref }}
|
||||||
|
submodules: recursive
|
||||||
|
- name: Set up Docker Buildx
|
||||||
|
uses: docker/setup-buildx-action@v4
|
||||||
|
- name: Login to Docker Hub
|
||||||
|
uses: docker/login-action@v4
|
||||||
|
with:
|
||||||
|
username: ${{ secrets.DOCKER_HUB_USERNAME }}
|
||||||
|
password: ${{ secrets.DOCKER_HUB_TOKEN }}
|
||||||
|
- name: Build and push by digest
|
||||||
|
id: build
|
||||||
|
uses: docker/build-push-action@v7
|
||||||
|
with:
|
||||||
|
context: .
|
||||||
|
file: packaging/docker/alpine/Dockerfile
|
||||||
|
platforms: ${{ matrix.platform }}
|
||||||
|
outputs: type=image,name=yuezk/globalprotect-openconnect,push-by-digest=true,name-canonical=true,push=true
|
||||||
|
- name: Verify CLI tools
|
||||||
|
env:
|
||||||
|
IMAGE: yuezk/globalprotect-openconnect
|
||||||
|
DIGEST: ${{ steps.build.outputs.digest }}
|
||||||
|
run: |
|
||||||
|
docker run --rm "$IMAGE@$DIGEST" --help
|
||||||
|
docker run --rm --entrypoint gpauth "$IMAGE@$DIGEST" --help
|
||||||
|
- name: Export digest
|
||||||
|
run: |
|
||||||
|
mkdir -p /tmp/digests
|
||||||
|
digest="${{ steps.build.outputs.digest }}"
|
||||||
|
touch "/tmp/digests/${digest#sha256:}"
|
||||||
|
- name: Upload digest
|
||||||
|
uses: actions/upload-artifact@v7
|
||||||
|
with:
|
||||||
|
name: digests-${{ env.PLATFORM_PAIR }}
|
||||||
|
path: /tmp/digests/*
|
||||||
|
if-no-files-found: error
|
||||||
|
retention-days: 1
|
||||||
|
|
||||||
build-gpgui:
|
build-gpgui:
|
||||||
needs:
|
needs:
|
||||||
- setup-matrix
|
- setup-matrix
|
||||||
@@ -251,6 +308,7 @@ jobs:
|
|||||||
- tarball
|
- tarball
|
||||||
- tarball-offline
|
- tarball-offline
|
||||||
- build-gp
|
- build-gp
|
||||||
|
- build-docker-image
|
||||||
- build-gpgui
|
- build-gpgui
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
@@ -277,3 +335,33 @@ jobs:
|
|||||||
RELEASE_TAG: ${{ github.event_name == 'workflow_dispatch' && 'snapshot' || github.ref_name }}
|
RELEASE_TAG: ${{ github.event_name == 'workflow_dispatch' && 'snapshot' || github.ref_name }}
|
||||||
run: |
|
run: |
|
||||||
cd gh-release/gp/scripts && ./gh-release.sh "$RELEASE_TAG"
|
cd gh-release/gp/scripts && ./gh-release.sh "$RELEASE_TAG"
|
||||||
|
|
||||||
|
publish-docker-image:
|
||||||
|
needs:
|
||||||
|
- build-docker-image
|
||||||
|
if: ${{ github.event_name == 'workflow_dispatch' || startsWith(github.ref, 'refs/tags/') }}
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Download digests
|
||||||
|
uses: actions/download-artifact@v8
|
||||||
|
with:
|
||||||
|
path: /tmp/digests
|
||||||
|
pattern: digests-*
|
||||||
|
merge-multiple: true
|
||||||
|
- name: Set up Docker Buildx
|
||||||
|
uses: docker/setup-buildx-action@v4
|
||||||
|
- name: Login to Docker Hub
|
||||||
|
uses: docker/login-action@v4
|
||||||
|
with:
|
||||||
|
username: ${{ secrets.DOCKER_HUB_USERNAME }}
|
||||||
|
password: ${{ secrets.DOCKER_HUB_TOKEN }}
|
||||||
|
- name: Publish Docker manifest
|
||||||
|
working-directory: /tmp/digests
|
||||||
|
env:
|
||||||
|
IMAGE: yuezk/globalprotect-openconnect
|
||||||
|
RELEASE_TAG: ${{ github.event_name == 'workflow_dispatch' && 'snapshot' || github.ref_name }}
|
||||||
|
run: |
|
||||||
|
docker buildx imagetools create -t "$IMAGE:$RELEASE_TAG" \
|
||||||
|
$(printf "$IMAGE@sha256:%s " *)
|
||||||
|
|
||||||
|
docker buildx imagetools inspect "$IMAGE:$RELEASE_TAG"
|
||||||
@@ -79,13 +79,24 @@ jobs:
|
|||||||
needs: [check, resolve-series]
|
needs: [check, resolve-series]
|
||||||
name: publish-ppa (${{ matrix.series }})
|
name: publish-ppa (${{ matrix.series }})
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
container:
|
||||||
|
image: ubuntu:${{ matrix.series }}
|
||||||
strategy:
|
strategy:
|
||||||
fail-fast: false
|
fail-fast: false
|
||||||
matrix: ${{ fromJSON(needs.resolve-series.outputs.matrix) }}
|
matrix: ${{ fromJSON(needs.resolve-series.outputs.matrix) }}
|
||||||
steps:
|
steps:
|
||||||
- uses: pnpm/action-setup@v5
|
- name: Install container tools
|
||||||
with:
|
run: |
|
||||||
version: 9
|
apt-get update
|
||||||
|
apt-get install -y ca-certificates curl gpg sudo
|
||||||
|
mkdir -p /etc/apt/keyrings
|
||||||
|
curl -fsSL https://cli.github.com/packages/githubcli-archive-keyring.gpg \
|
||||||
|
| gpg --dearmor -o /etc/apt/keyrings/githubcli-archive-keyring.gpg
|
||||||
|
chmod go+r /etc/apt/keyrings/githubcli-archive-keyring.gpg
|
||||||
|
echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/githubcli-archive-keyring.gpg] https://cli.github.com/packages stable main" \
|
||||||
|
> /etc/apt/sources.list.d/github-cli.list
|
||||||
|
apt-get update
|
||||||
|
apt-get install -y gh
|
||||||
- name: Prepare workspace
|
- name: Prepare workspace
|
||||||
run: rm -rf publish-ppa && mkdir publish-ppa
|
run: rm -rf publish-ppa && mkdir publish-ppa
|
||||||
- name: Download ${{ inputs.tag }} offline source code
|
- name: Download ${{ inputs.tag }} offline source code
|
||||||
|
|||||||
@@ -40,6 +40,11 @@ on:
|
|||||||
description: 'Build binary package'
|
description: 'Build binary package'
|
||||||
required: true
|
required: true
|
||||||
default: true
|
default: true
|
||||||
|
release-docker:
|
||||||
|
type: boolean
|
||||||
|
description: 'Publish Docker image'
|
||||||
|
required: true
|
||||||
|
default: true
|
||||||
gh-release:
|
gh-release:
|
||||||
type: boolean
|
type: boolean
|
||||||
description: 'Update GitHub release'
|
description: 'Update GitHub release'
|
||||||
@@ -84,7 +89,7 @@ jobs:
|
|||||||
}
|
}
|
||||||
|
|
||||||
const package = Object.entries(inputs)
|
const package = Object.entries(inputs)
|
||||||
.filter(([key, value]) => key.startsWith('release-') && value)
|
.filter(([key, value]) => key.startsWith('release-') && key !== 'release-docker' && value)
|
||||||
.map(([key, value]) => key.replace('release-', ''))
|
.map(([key, value]) => key.replace('release-', ''))
|
||||||
|
|
||||||
return JSON.stringify({
|
return JSON.stringify({
|
||||||
@@ -139,6 +144,109 @@ jobs:
|
|||||||
path: |
|
path: |
|
||||||
build-${{ matrix.package }}/artifacts/*
|
build-${{ matrix.package }}/artifacts/*
|
||||||
|
|
||||||
|
build-docker-image:
|
||||||
|
needs:
|
||||||
|
- check
|
||||||
|
if: ${{ inputs.release-docker }}
|
||||||
|
strategy:
|
||||||
|
fail-fast: false
|
||||||
|
matrix:
|
||||||
|
include:
|
||||||
|
- runner: ubuntu-latest
|
||||||
|
platform: linux/amd64
|
||||||
|
- runner: ubuntu-24.04-arm
|
||||||
|
platform: linux/arm64
|
||||||
|
runs-on: ${{ matrix.runner }}
|
||||||
|
steps:
|
||||||
|
- name: Prepare
|
||||||
|
run: |
|
||||||
|
platform=${{ matrix.platform }}
|
||||||
|
echo "PLATFORM_PAIR=${platform//\//-}" >> "$GITHUB_ENV"
|
||||||
|
- name: Prepare workspace
|
||||||
|
run: rm -rf docker-image && mkdir -p docker-image/source
|
||||||
|
|
||||||
|
- name: Download ${{ inputs.tag }} source code
|
||||||
|
env:
|
||||||
|
GH_TOKEN: ${{ secrets.GH_PAT }}
|
||||||
|
run: |
|
||||||
|
gh -R yuezk/GlobalProtect-openconnect \
|
||||||
|
release download ${{ inputs.tag }} \
|
||||||
|
--pattern '*[^offline].tar.gz' \
|
||||||
|
--dir docker-image
|
||||||
|
tar -xzf docker-image/*.tar.gz -C docker-image/source --strip-components=1
|
||||||
|
|
||||||
|
- name: Set up Docker Buildx
|
||||||
|
uses: docker/setup-buildx-action@v4
|
||||||
|
- name: Login to Docker Hub
|
||||||
|
uses: docker/login-action@v4
|
||||||
|
with:
|
||||||
|
username: ${{ secrets.DOCKER_HUB_USERNAME }}
|
||||||
|
password: ${{ secrets.DOCKER_HUB_TOKEN }}
|
||||||
|
- name: Build and push by digest
|
||||||
|
id: build
|
||||||
|
uses: docker/build-push-action@v7
|
||||||
|
with:
|
||||||
|
context: docker-image/source
|
||||||
|
file: docker-image/source/packaging/docker/alpine/Dockerfile
|
||||||
|
platforms: ${{ matrix.platform }}
|
||||||
|
outputs: type=image,name=yuezk/globalprotect-openconnect,push-by-digest=true,name-canonical=true,push=true
|
||||||
|
- name: Verify CLI tools
|
||||||
|
env:
|
||||||
|
IMAGE: yuezk/globalprotect-openconnect
|
||||||
|
DIGEST: ${{ steps.build.outputs.digest }}
|
||||||
|
run: |
|
||||||
|
docker run --rm "$IMAGE@$DIGEST" --help
|
||||||
|
docker run --rm --entrypoint gpauth "$IMAGE@$DIGEST" --help
|
||||||
|
- name: Export digest
|
||||||
|
run: |
|
||||||
|
mkdir -p /tmp/digests
|
||||||
|
digest="${{ steps.build.outputs.digest }}"
|
||||||
|
touch "/tmp/digests/${digest#sha256:}"
|
||||||
|
- name: Upload digest
|
||||||
|
uses: actions/upload-artifact@v7
|
||||||
|
with:
|
||||||
|
name: digests-${{ env.PLATFORM_PAIR }}
|
||||||
|
path: /tmp/digests/*
|
||||||
|
if-no-files-found: error
|
||||||
|
retention-days: 1
|
||||||
|
|
||||||
|
publish-docker-image:
|
||||||
|
needs:
|
||||||
|
- build-docker-image
|
||||||
|
if: ${{ inputs.release-docker }}
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Download digests
|
||||||
|
uses: actions/download-artifact@v8
|
||||||
|
with:
|
||||||
|
path: /tmp/digests
|
||||||
|
pattern: digests-*
|
||||||
|
merge-multiple: true
|
||||||
|
- name: Set up Docker Buildx
|
||||||
|
uses: docker/setup-buildx-action@v4
|
||||||
|
- name: Login to Docker Hub
|
||||||
|
uses: docker/login-action@v4
|
||||||
|
with:
|
||||||
|
username: ${{ secrets.DOCKER_HUB_USERNAME }}
|
||||||
|
password: ${{ secrets.DOCKER_HUB_TOKEN }}
|
||||||
|
- name: Publish Docker manifest
|
||||||
|
working-directory: /tmp/digests
|
||||||
|
env:
|
||||||
|
IMAGE: yuezk/globalprotect-openconnect
|
||||||
|
TAG: ${{ inputs.tag }}
|
||||||
|
run: |
|
||||||
|
VERSION="${TAG#v}"
|
||||||
|
tags=(-t "$IMAGE:$TAG")
|
||||||
|
|
||||||
|
if [[ "$TAG" =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
|
||||||
|
tags+=(-t "$IMAGE:$VERSION" -t "$IMAGE:latest")
|
||||||
|
fi
|
||||||
|
|
||||||
|
docker buildx imagetools create "${tags[@]}" \
|
||||||
|
$(printf "$IMAGE@sha256:%s " *)
|
||||||
|
|
||||||
|
docker buildx imagetools inspect "$IMAGE:$TAG"
|
||||||
|
|
||||||
gh-release:
|
gh-release:
|
||||||
needs:
|
needs:
|
||||||
- build
|
- build
|
||||||
|
|||||||
Reference in new issue
Block a user