Initial commit
This commit is contained in:
@@ -0,0 +1,38 @@
|
||||
name: CI
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [ "main", "master" ]
|
||||
pull_request:
|
||||
branches: [ "main", "master" ]
|
||||
|
||||
env:
|
||||
CARGO_TERM_COLOR: always
|
||||
|
||||
jobs:
|
||||
test:
|
||||
name: Test
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: dtolnay/rust-toolchain@stable
|
||||
- name: Run tests
|
||||
run: cargo test
|
||||
|
||||
build-linux:
|
||||
name: Build Linux
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: dtolnay/rust-toolchain@stable
|
||||
- name: Build
|
||||
run: cargo build --release
|
||||
|
||||
build-windows:
|
||||
name: Build Windows
|
||||
runs-on: windows-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: dtolnay/rust-toolchain@stable
|
||||
- name: Build
|
||||
run: cargo build --release
|
||||
@@ -0,0 +1,119 @@
|
||||
name: Release
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [ "main", "master" ]
|
||||
|
||||
jobs:
|
||||
check-release:
|
||||
runs-on: ubuntu-latest
|
||||
outputs:
|
||||
match: ${{ steps.check.outputs.match }}
|
||||
version: ${{ steps.check.outputs.version }}
|
||||
steps:
|
||||
- name: Check commit message
|
||||
id: check
|
||||
run: |
|
||||
COMMIT_MSG="${{ github.event.head_commit.message }}"
|
||||
if echo "$COMMIT_MSG" | grep -Eq 'Release [vV]?[0-9]+\.[0-9]+\.[0-9]+'; then
|
||||
VERSION=$(echo "$COMMIT_MSG" | grep -Eo 'Release [vV]?[0-9]+\.[0-9]+\.[0-9]+' | head -n1 | sed -E 's/Release //')
|
||||
echo "match=true" >> $GITHUB_OUTPUT
|
||||
echo "version=$VERSION" >> $GITHUB_OUTPUT
|
||||
else
|
||||
echo "match=false" >> $GITHUB_OUTPUT
|
||||
fi
|
||||
|
||||
build-release-assets:
|
||||
needs: check-release
|
||||
if: needs.check-release.outputs.match == 'true'
|
||||
strategy:
|
||||
matrix:
|
||||
include:
|
||||
- os: ubuntu-latest
|
||||
target: x86_64-unknown-linux-gnu
|
||||
- os: windows-latest
|
||||
target: x86_64-pc-windows-msvc
|
||||
runs-on: ${{ matrix.os }}
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: dtolnay/rust-toolchain@stable
|
||||
|
||||
- name: Build
|
||||
run: cargo build --release
|
||||
|
||||
- name: Build deb and rpm
|
||||
if: matrix.os == 'ubuntu-latest'
|
||||
run: |
|
||||
cargo install cargo-deb cargo-generate-rpm
|
||||
cargo deb
|
||||
cargo generate-rpm
|
||||
cp target/debian/*.deb convertis.deb
|
||||
cp target/generate-rpm/*.rpm convertis.rpm
|
||||
|
||||
- name: Rename exe
|
||||
if: matrix.os == 'windows-latest'
|
||||
run: copy target\release\convertis.exe convertis.exe
|
||||
|
||||
- name: Upload Linux Assets
|
||||
if: matrix.os == 'ubuntu-latest'
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: linux-assets
|
||||
path: |
|
||||
convertis.deb
|
||||
convertis.rpm
|
||||
|
||||
- name: Upload Windows Assets
|
||||
if: matrix.os == 'windows-latest'
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: windows-assets
|
||||
path: convertis.exe
|
||||
|
||||
publish-release:
|
||||
needs: [check-release, build-release-assets]
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
contents: write
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Download Linux Assets
|
||||
uses: actions/download-artifact@v4
|
||||
with:
|
||||
name: linux-assets
|
||||
|
||||
- name: Download Windows Assets
|
||||
uses: actions/download-artifact@v4
|
||||
with:
|
||||
name: windows-assets
|
||||
|
||||
- name: Generate Changelog
|
||||
run: |
|
||||
LAST_TAG=$(git describe --tags --abbrev=0 2>/dev/null || git rev-list --max-parents=0 HEAD)
|
||||
git log ${LAST_TAG}..HEAD --pretty=format:"- %s (%an)" > commits.txt
|
||||
|
||||
echo "## Changelog" > changelog.md
|
||||
|
||||
echo "### Features" >> changelog.md
|
||||
grep -i "^- feat:" commits.txt >> changelog.md || echo "No new features" >> changelog.md
|
||||
|
||||
echo "### Fixes" >> changelog.md
|
||||
grep -i "^- fix:" commits.txt >> changelog.md || echo "No fixes" >> changelog.md
|
||||
|
||||
echo "### Refactoring & Chores" >> changelog.md
|
||||
grep -i "^- refactor:\|^- chore:\|^- style:" commits.txt >> changelog.md || echo "No refactoring or chores" >> changelog.md
|
||||
|
||||
echo "### Others" >> changelog.md
|
||||
grep -vi "^- feat:\|^- fix:\|^- refactor:\|^- chore:\|^- style:" commits.txt >> changelog.md || echo "No other changes" >> changelog.md
|
||||
|
||||
- name: Create Release
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
run: |
|
||||
gh release create "v${{ needs.check-release.outputs.version }}" \
|
||||
--title "Release v${{ needs.check-release.outputs.version }}" \
|
||||
--notes-file changelog.md \
|
||||
convertis.deb convertis.rpm convertis.exe
|
||||
Reference in New Issue
Block a user