-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #146 from Vovke/main
ci: releases
- Loading branch information
Showing
3 changed files
with
83 additions
and
53 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters