6 Commits

Author SHA1 Message Date
ac7b67748d Merge pull request 'fixed release upload' (#3) from release/0.1.0 into main
All checks were successful
Release / Build and Release (push) Successful in 39s
Reviewed-on: nvrl/cenv-rs#3
2026-03-16 15:56:25 +01:00
8cee54007f fixed release upload 2026-03-16 15:56:18 +01:00
361df64b04 Merge pull request 'added version check + fixed release' (#2) from release/0.1.0 into main
Some checks failed
Release / Build and Release (push) Failing after 36s
Reviewed-on: nvrl/cenv-rs#2
2026-03-16 15:54:27 +01:00
0baf53b1eb added version check + fixed release 2026-03-16 15:54:06 +01:00
6eddd02fb4 Merge pull request 'release/0.1.0' (#1) from release/0.1.0 into main
Some checks failed
Release / Build and Release (push) Failing after 44s
Reviewed-on: nvrl/cenv-rs#1
2026-03-16 15:49:05 +01:00
93b2b82494 added gitea ci 2026-03-16 15:48:58 +01:00
2 changed files with 82 additions and 16 deletions

View File

@@ -2,6 +2,8 @@ name: Release
on:
push:
branches:
- main
tags:
- 'v*'
@@ -17,27 +19,56 @@ jobs:
uses: actions-rust-lang/setup-rust-toolchain@v1
with:
toolchain: stable
cache: false
- name: Get Version
id: get_version
run: |
VERSION=$(grep '^version =' Cargo.toml | head -n1 | cut -d '"' -f 2)
echo "VERSION=$VERSION" >> $GITHUB_OUTPUT
if [[ "${{ github.ref }}" == refs/tags/v* ]]; then
echo "TAG=${{ github.ref_name }}" >> $GITHUB_OUTPUT
else
echo "TAG=v$VERSION" >> $GITHUB_OUTPUT
fi
- name: Check if Release Exists
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 }}")
if [ "$HTTP_STATUS" = "200" ]; then
echo "EXISTS=true" >> $GITHUB_OUTPUT
echo "Release already exists for tag ${{ steps.get_version.outputs.TAG }}. Skipping creation."
else
echo "EXISTS=false" >> $GITHUB_OUTPUT
fi
- name: Build
run: cargo build --release
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
id: create_release
uses: https://github.com/actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Create Release and Upload Asset
if: steps.check_release.outputs.EXISTS == 'false'
uses: https://github.com/softprops/action-gh-release@v1
with:
tag_name: ${{ github.ref_name }}
release_name: Release ${{ github.ref_name }}
tag_name: ${{ steps.get_version.outputs.TAG }}
name: Release ${{ steps.get_version.outputs.TAG }}
body: |
Automated release for version ${{ steps.get_version.outputs.VERSION }}
Commit: ${{ github.sha }}
Branch: ${{ github.ref_name }}
files: target/release/cenv-${{ steps.get_version.outputs.TAG }}-linux-amd64
draft: false
prerelease: false
- name: Upload Release Asset
uses: https://github.com/actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./target/release/cenv
asset_name: cenv-${{ github.ref_name }}-linux-amd64
asset_content_type: application/octet-stream

View 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