1
0
mirror of https://github.com/v2fly/v2ray-core.git synced 2024-10-17 16:33:40 -04:00

image tags and timestamp

This commit is contained in:
Qusic 2023-12-13 19:11:12 +08:00 committed by Xiaokang Wang (Shelikhoo)
parent cef5b1ec56
commit 887280e848
2 changed files with 62 additions and 44 deletions

View File

@ -2,7 +2,9 @@ name: Release
on: on:
release: release:
types: [prereleased] types:
- prereleased
- released
push: push:
branches: branches:
- master - master
@ -176,6 +178,7 @@ jobs:
file_glob: true file_glob: true
file: ./v2ray-${{ steps.get_filename.outputs.ASSET_NAME }}.zip* file: ./v2ray-${{ steps.get_filename.outputs.ASSET_NAME }}.zip*
tag: ${{ github.ref }} tag: ${{ github.ref }}
overwrite: true
signature: signature:
runs-on: ubuntu-latest runs-on: ubuntu-latest
@ -249,6 +252,7 @@ jobs:
file_glob: true file_glob: true
file: build_artifacts/Release.unsigned* file: build_artifacts/Release.unsigned*
tag: ${{ github.ref }} tag: ${{ github.ref }}
overwrite: true
- name: Upload extra package - name: Upload extra package
uses: svenstaro/upload-release-action@v2 uses: svenstaro/upload-release-action@v2
@ -258,27 +262,10 @@ jobs:
file_glob: true file_glob: true
file: build_artifacts/v2ray-extra.zip file: build_artifacts/v2ray-extra.zip
tag: ${{ github.ref }} tag: ${{ github.ref }}
overwrite: true
buildContainer: buildContainer:
if: github.event_name == 'release' if: github.event_name == 'release'
needs: signature needs: signature
strategy:
fail-fast: false
matrix:
variant: [std, extra]
arch:
- v2Name: 32
containerName: 386
- v2Name: 64
containerName: amd64
- v2Name: arm32-v6
containerName: arm/v6
- v2Name: arm32-v7a
containerName: arm/v7
- v2Name: arm64-v8a
containerName: arm64
- v2Name: arm64-v8a
containerName: arm64/v8
name: Build And Push image name: Build And Push image
runs-on: ubuntu-latest runs-on: ubuntu-latest
env: env:
@ -286,6 +273,19 @@ jobs:
REGISTRY_PASSWORD: ${{ github.token }} REGISTRY_PASSWORD: ${{ github.token }}
IMAGE_REGISTRY: ghcr.io/${{ github.repository_owner }} IMAGE_REGISTRY: ghcr.io/${{ github.repository_owner }}
RELEASE_REPO: ${{ github.repository }} RELEASE_REPO: ${{ github.repository }}
VERSION: ${{ github.event.release.tag_name }}
TIMESTAMP: ${{ github.event.release.created_at }}
PRERELEASE: ${{ github.event.release.prerelease }}
VARIANTS: | # <v2ray variant>:<image tag suffix>
std:
extra:-extra
ARCHS: | # <v2ray arch name>:<container arch name>
32:386
64:amd64
arm32-v6:arm/v6
arm32-v7a:arm/v7
arm64-v8a:arm64
arm64-v8a:arm64/v8
steps: steps:
- uses: actions/checkout@v3 - uses: actions/checkout@v3
@ -296,26 +296,47 @@ jobs:
password: ${{ env.REGISTRY_PASSWORD }} password: ${{ env.REGISTRY_PASSWORD }}
registry: ${{ env.IMAGE_REGISTRY }} registry: ${{ env.IMAGE_REGISTRY }}
- name: Download Assets - name: Build Images
run: |
bash ./release/container/downloadAssets.sh ${{ github.ref_name }} ${{ matrix.arch.v2Name }} ${{ matrix.arch.containerName }} ${{ matrix.variant }}
- name: Buildah Action
id: build-image id: build-image
uses: redhat-actions/buildah-build@v2 run: |
with: image=v2ray
image: v2ray tags=
tags: ${{ github.ref_name }}-${{ matrix.arch.v2Name }}-${{ matrix.variant }}
containerfiles: | timestamp=$(date -d $TIMESTAMP +%s)
./release/container/Containerfile versions="$VERSION" # full version (v1.2.3)
build-args: | versions="$versions $(echo $VERSION | cut -d. -f1,2)" # minor version (v1.2)
TARGETPLATFORM=${{ matrix.arch.containerName }} if [ $PRERELEASE = false ]; then
VARIANT=${{ matrix.variant }} versions="$versions $(echo $VERSION | cut -d. -f1)" # major version (v1)
archs: ${{ matrix.arch.containerName }} versions="$versions latest"
context: context/linux/${{ matrix.arch.containerName }}/${{ matrix.variant }} fi
extra-args: |
--squash formatEach() {
--timestamp 0 format=$1
shift 1
echo "$@" | xargs -n1 | xargs -i echo "$format" | xargs
}
for variant in $VARIANTS; do
v2Variant=$(echo $variant | cut -d: -f1)
containerVariant=$(echo $variant | cut -d: -f2)
variantTags=$(formatEach "{}$containerVariant" $versions)
tags="$tags $variantTags"
for arch in $ARCHS; do
v2Arch=$(echo $arch | cut -d: -f1)
containerArch=$(echo $arch | cut -d: -f2)
bash ./release/container/downloadAssets.sh $VERSION $v2Arch $containerArch $v2Variant
buildah bud \
$(formatEach "--tag $image:{}" $variantTags) \
--file ./release/container/Containerfile \
--platform linux/$containerArch \
--timestamp $timestamp \
--squash \
./context/linux/$containerArch/$v2Variant
done
done
echo image=$image >> $GITHUB_OUTPUT
echo tags=$tags >> $GITHUB_OUTPUT
- name: Push To ghcr.io - name: Push To ghcr.io
uses: redhat-actions/push-to-registry@v2 uses: redhat-actions/push-to-registry@v2

View File

@ -1,9 +1,6 @@
FROM docker.io/library/golang@sha256:d19ee8512191c8b8e967246d4a7d0de4f4133a30bd9ce982e9b70a0c596dbf18 AS builder # golang:1.21.4 linux/amd64
FROM docker.io/library/golang@sha256:337543447173c2238c78d4851456760dcc57c1dfa8c3bcd94cbee8b0f7b32ad0 AS builder
FROM --platform=${TARGETPLATFORM} scratch FROM scratch
ARG TARGETPLATFORM
ARG VARIANT
COPY --from=builder /usr/share/zoneinfo /usr/share/zoneinfo COPY --from=builder /usr/share/zoneinfo /usr/share/zoneinfo
COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/