mirror of
https://github.com/yuaotian/go-cursor-help.git
synced 2025-06-08 12:32:06 +08:00
chore: update GitHub Actions workflows for improved error handling and version validation
- Downgraded actions in both auto-tag.yml and release.yml to v3 and v4 respectively for compatibility. - Enhanced error handling in the auto-tag workflow by adding checks for git fetch failures and validating version format. - Introduced additional validation for version numbers to ensure they remain within acceptable ranges. - Added a verification step in the release workflow to confirm Go installation, improving reliability.
This commit is contained in:
parent
deb1aafcb5
commit
1e4f2457c2
18
.github/workflows/auto-tag.yml
vendored
18
.github/workflows/auto-tag.yml
vendored
@ -15,18 +15,22 @@ permissions: write-all
|
|||||||
jobs:
|
jobs:
|
||||||
auto-tag:
|
auto-tag:
|
||||||
runs-on: ubuntu-22.04
|
runs-on: ubuntu-22.04
|
||||||
|
timeout-minutes: 10
|
||||||
outputs:
|
outputs:
|
||||||
version: ${{ steps.get_latest_tag.outputs.version }}
|
version: ${{ steps.get_latest_tag.outputs.version }}
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v3
|
||||||
with:
|
with:
|
||||||
fetch-depth: 0
|
fetch-depth: 0
|
||||||
|
|
||||||
- name: Get latest tag
|
- name: Get latest tag
|
||||||
id: get_latest_tag
|
id: get_latest_tag
|
||||||
run: |
|
run: |
|
||||||
set -e
|
set -euo pipefail
|
||||||
git fetch --tags || exit 1
|
git fetch --tags --force || {
|
||||||
|
echo "::error::Failed to fetch tags"
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
latest_tag=$(git tag -l 'v*' --sort=-v:refname | head -n 1)
|
latest_tag=$(git tag -l 'v*' --sort=-v:refname | head -n 1)
|
||||||
if [ -z "$latest_tag" ]; then
|
if [ -z "$latest_tag" ]; then
|
||||||
new_version="v0.1.0"
|
new_version="v0.1.0"
|
||||||
@ -42,12 +46,20 @@ jobs:
|
|||||||
|
|
||||||
- name: Validate version
|
- name: Validate version
|
||||||
run: |
|
run: |
|
||||||
|
set -euo pipefail
|
||||||
new_tag="${{ steps.get_latest_tag.outputs.version }}"
|
new_tag="${{ steps.get_latest_tag.outputs.version }}"
|
||||||
echo "Validating version: $new_tag"
|
echo "Validating version: $new_tag"
|
||||||
if [[ ! $new_tag =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
|
if [[ ! $new_tag =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
|
||||||
echo "::error::Invalid version format: $new_tag"
|
echo "::error::Invalid version format: $new_tag"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
major=$(echo $new_tag | cut -d. -f1 | tr -d 'v')
|
||||||
|
minor=$(echo $new_tag | cut -d. -f2)
|
||||||
|
patch=$(echo $new_tag | cut -d. -f3)
|
||||||
|
if [[ $major -gt 99 || $minor -gt 99 || $patch -gt 999 ]]; then
|
||||||
|
echo "::error::Version numbers out of valid range"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
echo "Version validation passed"
|
echo "Version validation passed"
|
||||||
|
|
||||||
- name: Create new tag
|
- name: Create new tag
|
||||||
|
17
.github/workflows/release.yml
vendored
17
.github/workflows/release.yml
vendored
@ -27,23 +27,24 @@ jobs:
|
|||||||
goreleaser:
|
goreleaser:
|
||||||
environment: production
|
environment: production
|
||||||
runs-on: ubuntu-22.04
|
runs-on: ubuntu-22.04
|
||||||
|
timeout-minutes: 15
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v3
|
||||||
with:
|
with:
|
||||||
fetch-depth: 0
|
fetch-depth: 0
|
||||||
lfs: true
|
lfs: true
|
||||||
submodules: recursive
|
submodules: recursive
|
||||||
|
|
||||||
- name: Set up Go
|
- name: Set up Go
|
||||||
uses: actions/setup-go@v5
|
uses: actions/setup-go@v4
|
||||||
with:
|
with:
|
||||||
go-version: "1.21"
|
go-version: "1.21"
|
||||||
cache: true
|
cache: true
|
||||||
|
|
||||||
- name: Import GPG key
|
- name: Import GPG key
|
||||||
id: import_gpg
|
id: import_gpg
|
||||||
uses: crazy-max/ghaction-import-gpg@v6
|
uses: crazy-max/ghaction-import-gpg@v5
|
||||||
with:
|
with:
|
||||||
gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }}
|
gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }}
|
||||||
passphrase: ${{ secrets.PASSPHRASE }}
|
passphrase: ${{ secrets.PASSPHRASE }}
|
||||||
@ -52,8 +53,15 @@ jobs:
|
|||||||
git_commit_gpgsign: true
|
git_commit_gpgsign: true
|
||||||
git_tag_gpgsign: true
|
git_tag_gpgsign: true
|
||||||
|
|
||||||
|
- name: Verify Go installation
|
||||||
|
run: |
|
||||||
|
go version || {
|
||||||
|
echo "::error::Go installation failed"
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
|
||||||
- name: Run GoReleaser
|
- name: Run GoReleaser
|
||||||
uses: goreleaser/goreleaser-action@v5
|
uses: goreleaser/goreleaser-action@v4
|
||||||
with:
|
with:
|
||||||
distribution: goreleaser
|
distribution: goreleaser
|
||||||
version: latest
|
version: latest
|
||||||
@ -62,5 +70,6 @@ jobs:
|
|||||||
GITHUB_TOKEN: ${{ secrets.RELEASE_TOKEN }}
|
GITHUB_TOKEN: ${{ secrets.RELEASE_TOKEN }}
|
||||||
GPG_FINGERPRINT: ${{ steps.import_gpg.outputs.fingerprint }}
|
GPG_FINGERPRINT: ${{ steps.import_gpg.outputs.fingerprint }}
|
||||||
VERSION: ${{ inputs.version }}
|
VERSION: ${{ inputs.version }}
|
||||||
|
continue-on-error: false
|
||||||
|
|
||||||
if: github.event_name == 'workflow_call' || startsWith(github.ref, 'refs/tags/v')
|
if: github.event_name == 'workflow_call' || startsWith(github.ref, 'refs/tags/v')
|
||||||
|
Loading…
x
Reference in New Issue
Block a user