Skip to content

.github/workflows/release.yaml #7

.github/workflows/release.yaml

.github/workflows/release.yaml #7

Workflow file for this run

name: auto-release
on:
schedule:
- cron: '0 0 */14 * *' # Runs every 14 days at midnight UTC
workflow_dispatch:
jobs:
create-tag-release:
runs-on: ubuntu-latest
strategy:
matrix:
os: [ubuntu-latest]
target: [x86_64-unknown-linux-gnu, aarch64-unknown-linux-gnu]
include:
# MacOS with arm64 needs a different runner architecture
- os: macos-latest
target: aarch64-apple-darwin
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Calculate next tag
id: tag_version
run: |
new_version=$(grep '^version = ' Cargo.toml | awk '{ print $3 }' | tr -d '"')
echo "New version: $new_version"
# Check if the tag already exists
if git rev-parse "v$new_version" >/dev/null 2>&1; then
echo "Tag v$new_version already exists. Exiting."
exit 1
fi
# Set output for other steps
echo "NEW_VERSION=v$new_version" >> $GITHUB_ENV
echo "NEW_VERSION=v$new_version"
- name: Install cross
run: |
cargo install cross
- name: Install target
run: |
rustup target add ${{ matrix.target }}
- name: Cross compile
run: |
cross build --target ${{ matrix.target }} --release
# Step 6: Compress build output for each architecture
- name: Compress artifacts
run: |
mkdir -p artifacts
tar -czvf artifacts/${{ matrix.target }}-build_artifacts.tar.gz -C target/${{ matrix.target }}/release .
# Step 7: Create the new tag
- name: Create new tag
run: |
git config user.name "github-actions"
git config user.email "[email protected]"
git tag ${{ env.NEW_VERSION }}
git push origin ${{ env.NEW_VERSION }}
# Step 8: Upload the release artifacts for this architecture
- name: Create GitHub Release and Upload Artifacts
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ env.NEW_VERSION }}
release_name: "Release ${{ env.NEW_VERSION }}"
body: "Automated release for version ${{ env.NEW_VERSION }}"
draft: false
prerelease: false
files: artifacts/${{ matrix.target }}-build_artifacts.tar.gz