mirror of
https://github.com/router-for-me/CLIProxyAPI.git
synced 2026-02-02 20:40:52 +08:00
Update workflows and build process for enhanced metadata injection
- Upgraded GitHub Actions (`actions/checkout` to v4, `actions/setup-go` to v4, `goreleaser-action` to v4). - Added detailed build metadata (`VERSION`, `COMMIT`, `BUILD_DATE`) to workflows. - Unified metadata injection into binaries and Docker images. - Enhanced `.goreleaser.yml` with checksum, snapshot, and changelog configurations.
This commit is contained in:
14
.github/workflows/docker-image.yml
vendored
14
.github/workflows/docker-image.yml
vendored
@@ -24,8 +24,11 @@ jobs:
|
|||||||
with:
|
with:
|
||||||
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
||||||
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
||||||
- name: Generate App Version
|
- name: Generate Build Metadata
|
||||||
run: echo APP_VERSION=`git describe --tags --always` >> $GITHUB_ENV
|
run: |
|
||||||
|
echo VERSION=`git describe --tags --always --dirty` >> $GITHUB_ENV
|
||||||
|
echo COMMIT=`git rev-parse --short HEAD` >> $GITHUB_ENV
|
||||||
|
echo BUILD_DATE=`date -u +%Y-%m-%dT%H:%M:%SZ` >> $GITHUB_ENV
|
||||||
- name: Build and push
|
- name: Build and push
|
||||||
uses: docker/build-push-action@v6
|
uses: docker/build-push-action@v6
|
||||||
with:
|
with:
|
||||||
@@ -35,8 +38,9 @@ jobs:
|
|||||||
linux/arm64
|
linux/arm64
|
||||||
push: true
|
push: true
|
||||||
build-args: |
|
build-args: |
|
||||||
APP_NAME=${{ env.APP_NAME }}
|
VERSION=${{ env.VERSION }}
|
||||||
APP_VERSION=${{ env.APP_VERSION }}
|
COMMIT=${{ env.COMMIT }}
|
||||||
|
BUILD_DATE=${{ env.BUILD_DATE }}
|
||||||
tags: |
|
tags: |
|
||||||
${{ env.DOCKERHUB_REPO }}:latest
|
${{ env.DOCKERHUB_REPO }}:latest
|
||||||
${{ env.DOCKERHUB_REPO }}:${{ env.APP_VERSION }}
|
${{ env.DOCKERHUB_REPO }}:${{ env.VERSION }}
|
||||||
|
|||||||
16
.github/workflows/release.yaml
vendored
16
.github/workflows/release.yaml
vendored
@@ -13,20 +13,26 @@ jobs:
|
|||||||
goreleaser:
|
goreleaser:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v4
|
||||||
with:
|
with:
|
||||||
fetch-depth: 0
|
fetch-depth: 0
|
||||||
- run: git fetch --force --tags
|
- run: git fetch --force --tags
|
||||||
- uses: actions/setup-go@v3
|
- uses: actions/setup-go@v4
|
||||||
with:
|
with:
|
||||||
go-version: '>=1.24.0'
|
go-version: '>=1.24.0'
|
||||||
cache: true
|
cache: true
|
||||||
- name: "Set custom GORELEASER_CURRENT_TAG"
|
- name: Generate Build Metadata
|
||||||
run: echo "GORELEASER_CURRENT_TAG=${{ github.event.inputs.tag }}" >> $GITHUB_ENV
|
run: |
|
||||||
- uses: goreleaser/goreleaser-action@v3
|
echo VERSION=`git describe --tags --always --dirty` >> $GITHUB_ENV
|
||||||
|
echo COMMIT=`git rev-parse --short HEAD` >> $GITHUB_ENV
|
||||||
|
echo BUILD_DATE=`date -u +%Y-%m-%dT%H:%M:%SZ` >> $GITHUB_ENV
|
||||||
|
- uses: goreleaser/goreleaser-action@v4
|
||||||
with:
|
with:
|
||||||
distribution: goreleaser
|
distribution: goreleaser
|
||||||
version: latest
|
version: latest
|
||||||
args: release --clean
|
args: release --clean
|
||||||
env:
|
env:
|
||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
VERSION: ${{ env.VERSION }}
|
||||||
|
COMMIT: ${{ env.COMMIT }}
|
||||||
|
BUILD_DATE: ${{ env.BUILD_DATE }}
|
||||||
|
|||||||
@@ -10,10 +10,7 @@ builds:
|
|||||||
main: ./cmd/server/
|
main: ./cmd/server/
|
||||||
binary: cli-proxy-api
|
binary: cli-proxy-api
|
||||||
ldflags:
|
ldflags:
|
||||||
- -s -w
|
- -s -w -X 'main.Version={{.Version}}' -X 'main.Commit={{.ShortCommit}}' -X 'main.BuildDate={{.Date}}'
|
||||||
- -X 'main.Version={{.Version}}'
|
|
||||||
- -X 'main.Commit={{.ShortCommit}}'
|
|
||||||
- -X 'main.BuildDate={{.Date}}'
|
|
||||||
archives:
|
archives:
|
||||||
- id: "cli-proxy-api"
|
- id: "cli-proxy-api"
|
||||||
format: tar.gz
|
format: tar.gz
|
||||||
@@ -25,3 +22,16 @@ archives:
|
|||||||
- README.md
|
- README.md
|
||||||
- README_CN.md
|
- README_CN.md
|
||||||
- config.example.yaml
|
- config.example.yaml
|
||||||
|
|
||||||
|
checksum:
|
||||||
|
name_template: 'checksums.txt'
|
||||||
|
|
||||||
|
snapshot:
|
||||||
|
name_template: "{{ incpatch .Version }}-next"
|
||||||
|
|
||||||
|
changelog:
|
||||||
|
sort: asc
|
||||||
|
filters:
|
||||||
|
exclude:
|
||||||
|
- '^docs:'
|
||||||
|
- '^test:'
|
||||||
Reference in New Issue
Block a user