Skip to content

Commit

Permalink
feat: releases
Browse files Browse the repository at this point in the history
  • Loading branch information
Vovke committed Nov 25, 2024
1 parent 93caca5 commit 7e96b47
Show file tree
Hide file tree
Showing 3 changed files with 83 additions and 53 deletions.
83 changes: 83 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
name: Build and Release

on:
push:
tags:
- 'v*'

jobs:
build-and-release:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Install Rust
uses: actions-rs/toolchain@v1
with:
toolchain: stable

- name: Build release binary
run: |
cargo build --release
mkdir -p dist
cp target/release/kalatori dist/
- name: Extract changelog section
run: |
VERSION=${{ github.ref_name }}
CLEAN_VERSION=$(echo $VERSION | sed 's/^v//')
sed -n "/^## \\[$CLEAN_VERSION\\]/,/^## \\[/p" CHANGELOG.md | sed '$d' > dist/CHANGELOG_${VERSION}.md
echo "### 📦 Docker Image: " >> dist/CHANGELOG_${VERSION}.md
echo "Docker Image: \`docker pull ${{ secrets.DOCKER_USERNAME }}/kalatori:${CLEAN_VERSION}\`" >> dist/CHANGELOG_${VERSION}.md
echo "Extracted changelog:"
cat dist/CHANGELOG_${VERSION}.md
- name: Upload artifacts
uses: actions/upload-artifact@v3
with:
name: kalatori-${{ github.ref_name }}
path: dist/

- name: Log in to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_TOKEN }}

- name: Build and push Docker image
run: |
IMAGE_NAME="${{ secrets.DOCKER_USERNAME }}/kalatori"
TAG="${{ github.ref_name }}"
CLEAN_TAG=$(echo $TAG | sed 's/^v//')
docker build -t $IMAGE_NAME:$CLEAN_TAG .
docker tag $IMAGE_NAME:$CLEAN_TAG $IMAGE_NAME:latest
docker push $IMAGE_NAME:$CLEAN_TAG
docker push $IMAGE_NAME:latest
- name: Create GitHub Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.ref_name }}
release_name: ${{ github.ref_name }}
body_path: dist/CHANGELOG_${{ github.ref_name }}.md
draft: false
prerelease: false

- name: Upload release assets
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: dist/kalatori
asset_name: kalatori-${{ github.ref_name }}-linux-x86_64
asset_content_type: application/octet-stream
48 changes: 0 additions & 48 deletions .github/workflows/rust-cargo-build.yml

This file was deleted.

5 changes: 0 additions & 5 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,4 @@ COPY --from=builder /usr/src/kalatori/target/release/kalatori /app/kalatori

EXPOSE 16726

ENV KALATORI_HOST="0.0.0.0:16726"
ENV KALATORI_SEED="bottom drive obey lake curtain smoke basket hold race lonely fit walk"
ENV KALATORI_RECIPIENT="5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY"
ENV KALATORI_REMARK="test"

CMD ["/app/kalatori"]

0 comments on commit 7e96b47

Please sign in to comment.