2024-09-29 03:30:32 +02:00
|
|
|
version: '1'
|
|
|
|
name: Release Version
|
|
|
|
|
|
|
|
on:
|
|
|
|
push:
|
|
|
|
branches:
|
|
|
|
- main
|
|
|
|
|
|
|
|
jobs:
|
|
|
|
build:
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
|
|
|
- name: Checkout repository
|
|
|
|
uses: actions/checkout@v2
|
|
|
|
|
|
|
|
- name: Set up Go
|
|
|
|
uses: actions/setup-go@v2
|
|
|
|
with:
|
|
|
|
go-version: '1.23.1'
|
|
|
|
|
|
|
|
- name: Build Go binary
|
|
|
|
run: |
|
|
|
|
go mod tidy
|
|
|
|
go build -o s3-client
|
|
|
|
|
2024-09-29 03:47:23 +02:00
|
|
|
- name: Get latest commit ID
|
|
|
|
id: get_commit
|
|
|
|
run: |
|
|
|
|
commit_id=$(git rev-parse HEAD)
|
|
|
|
echo "commit_id=$commit_id" >> $GITHUB_ENV
|
|
|
|
|
|
|
|
- name: Get latest version and increment
|
2024-09-29 03:30:32 +02:00
|
|
|
id: create_version
|
|
|
|
run: |
|
|
|
|
latest_version=$(git describe --tags --abbrev=0 || echo "v0.0.0")
|
|
|
|
new_version=$(echo $latest_version | awk -F. '{printf "v%d.%d.%d", $1, $2, $3+1}')
|
2024-09-29 03:47:23 +02:00
|
|
|
|
|
|
|
if git rev-parse "$new_version" >/dev/null 2>&1; then
|
|
|
|
echo "Tag $new_version already exists. Exiting."
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2024-09-29 03:30:32 +02:00
|
|
|
echo "new_version=$new_version" >> $GITHUB_ENV
|
|
|
|
|
|
|
|
git tag $new_version
|
|
|
|
git push origin $new_version
|
|
|
|
|
|
|
|
- name: Create Release
|
2024-09-29 03:51:20 +02:00
|
|
|
id: create_release
|
2024-09-29 03:30:32 +02:00
|
|
|
uses: actions/create-release@v1
|
|
|
|
with:
|
|
|
|
tag_name: ${{ env.new_version }}
|
|
|
|
release_name: Release ${{ env.new_version }}
|
2024-09-29 03:42:53 +02:00
|
|
|
release_description: |
|
|
|
|
Automatic release by Gitea CI
|
|
|
|
Release version ${{ env.new_version }}.
|
|
|
|
Commit ID: ${{ env.commit_id }}
|
2024-09-29 03:30:32 +02:00
|
|
|
draft: false
|
|
|
|
prerelease: false
|
|
|
|
env:
|
2024-09-29 04:06:39 +02:00
|
|
|
GITEA_TOKEN: ${{ secrets.GITEA_TOKEN }}
|
|
|
|
GITHUB_TOKEN: ${{ secrets.GITEA_TOKEN }}
|
2024-09-29 03:30:32 +02:00
|
|
|
|
2024-09-29 03:51:20 +02:00
|
|
|
- name: Save release URL
|
|
|
|
run: echo "upload_url=${{ steps.create_release.outputs.upload_url }}" >> $GITHUB_ENV
|
|
|
|
|
2024-09-29 03:30:32 +02:00
|
|
|
- name: Upload Go binary to release
|
|
|
|
uses: actions/upload-release-asset@v1
|
|
|
|
with:
|
2024-09-29 03:51:20 +02:00
|
|
|
upload_url: ${{ env.upload_url }}
|
2024-09-29 03:36:12 +02:00
|
|
|
asset_path: ./s3-client
|
|
|
|
asset_name: s3-client_${{ env.new_version }}_linux_amd64
|
2024-09-29 04:03:07 +02:00
|
|
|
asset_content_type: application/octet-stream
|