ci: restrict workflows to main branch and refactor release process to use cross-compilation for multi-platform artifact generation
CI / Build Windows (push) Has been cancelled
Release / check-release (push) Successful in 14s
Release / build_executable (convertis, x86_64-unknown-linux-gnu) (push) Has been skipped
Release / build_executable (convertis, x86_64-unknown-linux-musl) (push) Has been skipped
Release / build_executable (convertis.exe, x86_64-pc-windows-gnu) (push) Has been skipped
Release / build_package (x86_64-unknown-linux-gnu, deb-gnu) (push) Has been skipped
Release / build_package (x86_64-pc-windows-gnu, exe) (push) Has been skipped
Release / build_package (x86_64-unknown-linux-musl, deb-musl) (push) Has been skipped
Release / build_package (x86_64-unknown-linux-gnu, rpm-gnu) (push) Has been skipped
Release / build_package (x86_64-unknown-linux-musl, rpm-musl) (push) Has been skipped
Release / publish-release (push) Has been skipped
CI / Test (push) Successful in 2m15s
CI / Build Linux (push) Successful in 2m40s
CI / Build Windows (push) Has been cancelled
Release / check-release (push) Successful in 14s
Release / build_executable (convertis, x86_64-unknown-linux-gnu) (push) Has been skipped
Release / build_executable (convertis, x86_64-unknown-linux-musl) (push) Has been skipped
Release / build_executable (convertis.exe, x86_64-pc-windows-gnu) (push) Has been skipped
Release / build_package (x86_64-unknown-linux-gnu, deb-gnu) (push) Has been skipped
Release / build_package (x86_64-pc-windows-gnu, exe) (push) Has been skipped
Release / build_package (x86_64-unknown-linux-musl, deb-musl) (push) Has been skipped
Release / build_package (x86_64-unknown-linux-gnu, rpm-gnu) (push) Has been skipped
Release / build_package (x86_64-unknown-linux-musl, rpm-musl) (push) Has been skipped
Release / publish-release (push) Has been skipped
CI / Test (push) Successful in 2m15s
CI / Build Linux (push) Successful in 2m40s
This commit is contained in:
@@ -2,9 +2,9 @@ name: CI
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [ "main", "master" ]
|
||||
branches: [ "main" ]
|
||||
pull_request:
|
||||
branches: [ "main", "master" ]
|
||||
branches: [ "main" ]
|
||||
|
||||
env:
|
||||
CARGO_TERM_COLOR: always
|
||||
|
||||
@@ -2,7 +2,7 @@ name: Release
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [ "main", "master" ]
|
||||
branches: [ "main" ]
|
||||
|
||||
jobs:
|
||||
check-release:
|
||||
@@ -23,55 +23,107 @@ jobs:
|
||||
echo "match=false" >> $GITHUB_OUTPUT
|
||||
fi
|
||||
|
||||
build-release-assets:
|
||||
build_executable:
|
||||
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 }}
|
||||
- target: x86_64-unknown-linux-gnu
|
||||
binary: convertis
|
||||
- target: x86_64-pc-windows-gnu
|
||||
binary: convertis.exe
|
||||
- target: x86_64-unknown-linux-musl
|
||||
binary: convertis
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
name: Checkout repo
|
||||
|
||||
- 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: Set up Rust Toolchain
|
||||
with:
|
||||
targets: ${{ matrix.target }}
|
||||
|
||||
- name: Upload Linux Assets
|
||||
if: matrix.os == 'ubuntu-latest'
|
||||
- name: Install cross-platform linkers
|
||||
run: |
|
||||
sudo apt-get update
|
||||
if [ "${{ matrix.target }}" = "x86_64-pc-windows-gnu" ]; then
|
||||
sudo apt-get install -y mingw-w64
|
||||
elif [ "${{ matrix.target }}" = "x86_64-unknown-linux-musl" ]; then
|
||||
sudo apt-get install -y musl-tools
|
||||
fi
|
||||
|
||||
- name: Build
|
||||
run: cargo build --release --target ${{ matrix.target }}
|
||||
|
||||
- name: Upload Executable Artifact
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: linux-assets
|
||||
path: |
|
||||
convertis.deb
|
||||
convertis.rpm
|
||||
|
||||
- name: Upload Windows Assets
|
||||
if: matrix.os == 'windows-latest'
|
||||
name: bin-${{ matrix.target }}
|
||||
path: target/${{ matrix.target }}/release/${{ matrix.binary }}
|
||||
|
||||
build_package:
|
||||
needs: build_executable
|
||||
if: needs.check-release.outputs.match == 'true'
|
||||
strategy:
|
||||
matrix:
|
||||
include:
|
||||
- type: deb-gnu
|
||||
target: x86_64-unknown-linux-gnu
|
||||
- type: deb-musl
|
||||
target: x86_64-unknown-linux-musl
|
||||
- type: rpm-gnu
|
||||
target: x86_64-unknown-linux-gnu
|
||||
- type: rpm-musl
|
||||
target: x86_64-unknown-linux-musl
|
||||
- type: exe
|
||||
target: x86_64-pc-windows-gnu
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- name: Download compiled binary
|
||||
uses: actions/download-artifact@v4
|
||||
with:
|
||||
name: bin-${{ matrix.target }}
|
||||
path: target/${{ matrix.target }}/release/
|
||||
|
||||
- name: Install deb build dependencies
|
||||
if: startsWith(matrix.type, 'deb-')
|
||||
run: cargo install cargo-deb
|
||||
|
||||
- name: Install rpm build dependencies
|
||||
if: startsWith(matrix.type, 'rpm-')
|
||||
run: cargo install cargo-generate-rpm
|
||||
|
||||
- name: Build deb
|
||||
if: startsWith(matrix.type, 'deb-')
|
||||
run: cargo deb --no-build --target ${{ matrix.target }}
|
||||
|
||||
- name: Build rpm
|
||||
if: startsWith(matrix.type, 'rpm-')
|
||||
run: cargo generate-rpm --target-dir target/${{ matrix.target }}
|
||||
|
||||
- name: Gather packages for upload
|
||||
run: |
|
||||
mkdir -p dist/
|
||||
if [ "${{ matrix.type }}" = "exe" ]; then
|
||||
cp target/${{ matrix.target }}/release/convertis.exe dist/
|
||||
elif [[ "${{ matrix.type }}" == deb-* ]]; then
|
||||
cp target/${{ matrix.target }}/debian/*.deb dist/
|
||||
elif [[ "${{ matrix.type }}" == rpm-* ]]; then
|
||||
cp target/${{ matrix.target }}/generate-rpm/*.rpm dist/
|
||||
fi
|
||||
|
||||
- name: Upload Package Artifact
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: windows-assets
|
||||
path: convertis.exe
|
||||
name: pkg-${{ matrix.type }}
|
||||
path: dist/*
|
||||
|
||||
publish-release:
|
||||
needs: [check-release, build-release-assets]
|
||||
needs: [check-release, build_package]
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
contents: write
|
||||
@@ -79,16 +131,13 @@ jobs:
|
||||
- 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
|
||||
- name: Download All Packages
|
||||
uses: actions/download-artifact@v4
|
||||
with:
|
||||
name: windows-assets
|
||||
pattern: pkg-*
|
||||
path: all-packages/
|
||||
merge-multiple: true
|
||||
|
||||
- name: Generate Changelog
|
||||
run: |
|
||||
@@ -109,11 +158,12 @@ jobs:
|
||||
echo "### Others" >> changelog.md
|
||||
grep -vi "^- feat:\|^- fix:\|^- refactor:\|^- chore:\|^- style:" commits.txt >> changelog.md || echo "No other changes" >> changelog.md
|
||||
|
||||
- name: Create Release
|
||||
- name: Create Gitea Release
|
||||
uses: softprops/action-gh-release@v2
|
||||
with:
|
||||
tag_name: v${{ needs.check-release.outputs.version }}
|
||||
name: Release v${{ needs.check-release.outputs.version }}
|
||||
body_path: changelog.md
|
||||
files: all-packages/*
|
||||
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
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
Reference in New Issue
Block a user