Compare commits
4 Commits
6eddd02fb4
...
v0.1.0
| Author | SHA1 | Date | |
|---|---|---|---|
| ac7b67748d | |||
| 8cee54007f | |||
| 361df64b04 | |||
| 0baf53b1eb |
@@ -19,6 +19,7 @@ jobs:
|
|||||||
uses: actions-rust-lang/setup-rust-toolchain@v1
|
uses: actions-rust-lang/setup-rust-toolchain@v1
|
||||||
with:
|
with:
|
||||||
toolchain: stable
|
toolchain: stable
|
||||||
|
cache: false
|
||||||
|
|
||||||
- name: Get Version
|
- name: Get Version
|
||||||
id: get_version
|
id: get_version
|
||||||
@@ -31,30 +32,43 @@ jobs:
|
|||||||
echo "TAG=v$VERSION" >> $GITHUB_OUTPUT
|
echo "TAG=v$VERSION" >> $GITHUB_OUTPUT
|
||||||
fi
|
fi
|
||||||
|
|
||||||
- name: Build
|
- name: Check if Release Exists
|
||||||
run: cargo build --release
|
id: check_release
|
||||||
|
shell: bash
|
||||||
|
run: |
|
||||||
|
# Use curl to check if a release for the current TAG already exists on Gitea
|
||||||
|
# This prevents the workflow from failing if a push to main doesn't update the version
|
||||||
|
# Assuming standard Gitea API (e.g., https://gitea.example.com/api/v1/repos/{owner}/{repo}/releases/tags/{tag})
|
||||||
|
# github.repository is usually 'owner/repo'
|
||||||
|
HTTP_STATUS=$(curl -s -o /dev/null -w "%{http_code}" \
|
||||||
|
-H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
|
||||||
|
"${{ github.server_url }}/api/v1/repos/${{ github.repository }}/releases/tags/${{ steps.get_version.outputs.TAG }}")
|
||||||
|
|
||||||
- name: Create Release
|
if [ "$HTTP_STATUS" = "200" ]; then
|
||||||
id: create_release
|
echo "EXISTS=true" >> $GITHUB_OUTPUT
|
||||||
uses: https://github.com/actions/create-release@v1
|
echo "Release already exists for tag ${{ steps.get_version.outputs.TAG }}. Skipping creation."
|
||||||
env:
|
else
|
||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
echo "EXISTS=false" >> $GITHUB_OUTPUT
|
||||||
|
fi
|
||||||
|
|
||||||
|
- name: Build
|
||||||
|
if: steps.check_release.outputs.EXISTS == 'false'
|
||||||
|
run: |
|
||||||
|
cargo build --release
|
||||||
|
mv target/release/cenv target/release/cenv-${{ steps.get_version.outputs.TAG }}-linux-amd64
|
||||||
|
|
||||||
|
- name: Create Release and Upload Asset
|
||||||
|
if: steps.check_release.outputs.EXISTS == 'false'
|
||||||
|
uses: https://github.com/softprops/action-gh-release@v1
|
||||||
with:
|
with:
|
||||||
tag_name: ${{ steps.get_version.outputs.TAG }}
|
tag_name: ${{ steps.get_version.outputs.TAG }}
|
||||||
release_name: Release ${{ steps.get_version.outputs.TAG }}
|
name: Release ${{ steps.get_version.outputs.TAG }}
|
||||||
body: |
|
body: |
|
||||||
Automated release for version ${{ steps.get_version.outputs.VERSION }}
|
Automated release for version ${{ steps.get_version.outputs.VERSION }}
|
||||||
Commit: ${{ github.sha }}
|
Commit: ${{ github.sha }}
|
||||||
Branch: ${{ github.ref_name }}
|
Branch: ${{ github.ref_name }}
|
||||||
|
files: target/release/cenv-${{ steps.get_version.outputs.TAG }}-linux-amd64
|
||||||
draft: false
|
draft: false
|
||||||
prerelease: false
|
prerelease: false
|
||||||
|
|
||||||
- name: Upload Release Asset
|
|
||||||
uses: https://github.com/actions/upload-release-asset@v1
|
|
||||||
env:
|
env:
|
||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
with:
|
|
||||||
upload_url: ${{ steps.create_release.outputs.upload_url }}
|
|
||||||
asset_path: ./target/release/cenv
|
|
||||||
asset_name: cenv-${{ steps.get_version.outputs.TAG }}-linux-amd64
|
|
||||||
asset_content_type: application/octet-stream
|
|
||||||
|
|||||||
35
.gitea/workflows/version-check.yaml
Normal file
35
.gitea/workflows/version-check.yaml
Normal file
@@ -0,0 +1,35 @@
|
|||||||
|
name: Version Check
|
||||||
|
|
||||||
|
on:
|
||||||
|
pull_request:
|
||||||
|
branches:
|
||||||
|
- main
|
||||||
|
paths:
|
||||||
|
- 'Cargo.toml'
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
check-version:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Checkout repository
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
with:
|
||||||
|
fetch-depth: 0
|
||||||
|
|
||||||
|
- name: Compare versions
|
||||||
|
shell: bash
|
||||||
|
run: |
|
||||||
|
NEW_VERSION=$(grep -m 1 '^version =' Cargo.toml | cut -d '"' -f 2)
|
||||||
|
|
||||||
|
git fetch origin ${{ github.base_ref }}
|
||||||
|
OLD_VERSION=$(git show origin/${{ github.base_ref }}:Cargo.toml | grep -m 1 '^version =' | cut -d '"' -f 2)
|
||||||
|
|
||||||
|
echo "Old version (main): $OLD_VERSION"
|
||||||
|
echo "New version (PR): $NEW_VERSION"
|
||||||
|
|
||||||
|
if [ "$NEW_VERSION" = "$OLD_VERSION" ]; then
|
||||||
|
echo "Error: Cargo.toml version has not been updated in this PR!"
|
||||||
|
exit 1
|
||||||
|
else
|
||||||
|
echo "Success: Version updated from $OLD_VERSION to $NEW_VERSION"
|
||||||
|
fi
|
||||||
Reference in New Issue
Block a user