Skip to content

update release

update release #19

Workflow file for this run

name: Rust CI/CD
on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
release:
types: [created]
env:
CARGO_TERM_COLOR: always
RUST_BACKTRACE: 1
jobs:
check:
name: Check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
override: true
- uses: actions-rs/cargo@v1
with:
command: check
test:
name: Test Suite
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
override: true
- uses: actions-rs/cargo@v1
with:
command: test
args: --all-features --test main -- --nocapture
fmt:
name: Rustfmt
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
override: true
- run: rustup component add rustfmt
- uses: actions-rs/cargo@v1
with:
command: fmt
args: --all -- --check
clippy:
name: Clippy
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
override: true
- run: rustup component add clippy
- uses: actions-rs/cargo@v1
with:
command: clippy
args: -- -D warnings
docs:
name: Documentation
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
override: true
- name: Install mdBook
run: cargo install mdbook
- name: Setup mdBook if not exists
run: |
if [ ! -d "docs" ]; then
mkdir docs
cd docs
mdbook init
echo "# ServerForge" > src/chapter_1.md
echo "# Summary" > src/SUMMARY.md
echo "" >> src/SUMMARY.md
echo "- [Chapter 1](./chapter_1.md)" >> src/SUMMARY.md
fi
- name: Build API docs
uses: actions-rs/cargo@v1
with:
command: doc
args: --no-deps --all-features
- name: Build mdBook docs
run: mdbook build docs
- name: Combine docs
run: |
mkdir -p ./public
cp -r ./target/doc ./public/api
cp -r ./docs/book ./public/guide
echo '<meta http-equiv="refresh" content="0; url=serverforge/index.html">' > ./public/index.html
- name: Deploy to GitHub Pages
uses: peaceiris/actions-gh-pages@v3
if: github.ref == 'refs/heads/main'
with:
github_token: ${{ secrets.TOKEN }}
publish_dir: ./public
force_orphan: true
publish-dry-run:
name: Publish Dry Run
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
override: true
- uses: actions-rs/cargo@v1
with:
command: publish
args: --dry-run
release:
name: Release
needs: [ check, fmt, docs ]
if: github.event_name == 'release' && github.event.action == 'created'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
override: true
target: x86_64-unknown-linux-gnu
- name: Build
uses: actions-rs/cargo@v1
with:
command: build
args: --release --target x86_64-unknown-linux-gnu
- name: Package
run: |
cd target/x86_64-unknown-linux-gnu/release
echo "Contents of release directory:"
ls -la
BINARY_NAME="server_forge"
if [ ! -f "$BINARY_NAME" ]; then
echo "Error: Expected binary $BINARY_NAME not found"
exit 1
fi
echo "Found binary: $BINARY_NAME"
ARCHIVE_NAME="server_forge-x86_64-unknown-linux-gnu.tar.gz"
tar czvf "../../../$ARCHIVE_NAME" "$BINARY_NAME"
echo "Contents of current directory after creating archive:"
ls -la
cd ../../../
echo "Contents of root directory:"
ls -la
echo "Archive details:"
ls -l $ARCHIVE_NAME
echo "Full path of archive:"
readlink -f $ARCHIVE_NAME
echo "Searching for archive:"
find . -name "$ARCHIVE_NAME"
- name: Upload binary to release
with:
repo_token: ${{ secrets.TOKEN }}
file: server_forge-x86_64-unknown-linux-gnu.tar.gz
asset_name: server_forge-x86_64-unknown-linux-gnu.tar.gz
tag: ${{ github.ref }}
overwrite: true
- name: Debug - List all files
if: failure()
run: |
echo "Contents of current directory:"
ls -R
echo "Searching for archive in entire workspace:"
find $GITHUB_WORKSPACE -name "server_forge-x86_64-unknown-linux-gnu.tar.gz"
publish-crates-io:
name: Publish to crates.io
needs: [release]
if: github.event_name == 'release' && github.event.action == 'created'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
override: true
- uses: actions-rs/cargo@v1
with:
command: publish
args: --token ${{ secrets.CRATES_IO_TOKEN }}
linux-packages:
name: Create Linux Packages
needs: [release]
if: github.event_name == 'release' && github.event.action == 'created'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Create DEB package
run: |
mkdir -p serverforge_${{ github.ref_name }}_amd64/DEBIAN
echo "Package: serverforge
Version: ${{ github.ref_name }}
Architecture: amd64
Maintainer: Chidozie C. Okafor <chidosiky2015@gmail.com>
Description: ServerForge - A robust server setup and maintenance tool" > serverforge_${{ github.ref_name }}_amd64/DEBIAN/control
mkdir -p serverforge_${{ github.ref_name }}_amd64/usr/local/bin
cp target/x86_64-unknown-linux-gnu/release/serverforge serverforge_${{ github.ref_name }}_amd64/usr/local/bin/
dpkg-deb --build serverforge_${{ github.ref_name }}_amd64
- name: Create RPM package
run: |
mkdir -p ~/rpmbuild/{SPECS,SOURCES}
cp target/x86_64-unknown-linux-gnu/release/serverforge ~/rpmbuild/SOURCES/
echo "Name: serverforge
Version: ${{ github.ref_name }}
Release: 1
Summary: ServerForge - A robust server setup and maintenance tool
License: MIT
%description
ServerForge is a robust server setup and maintenance tool.
%files
/usr/local/bin/serverforge
%install
mkdir -p %{buildroot}/usr/local/bin
cp %{_sourcedir}/serverforge %{buildroot}/usr/local/bin/
%clean
rm -rf %{buildroot}" > ~/rpmbuild/SPECS/serverforge.spec
rpmbuild -ba ~/rpmbuild/SPECS/serverforge.spec
- name: Upload Linux packages
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.TOKEN }}
with:
upload_url: ${{ github.event.release.upload_url }}
asset_path: |
./serverforge_${{ github.ref_name }}_amd64.deb
~/rpmbuild/RPMS/x86_64/serverforge-${{ github.ref_name }}-1.x86_64.rpm
asset_name: |
serverforge_${{ github.ref_name }}_amd64.deb
serverforge-${{ github.ref_name }}-1.x86_64.rpm
asset_content_type: application/octet-stream