Skip to content

build-release

build-release #38

Workflow file for this run

## Workflow triggered when issuing a new release
name: build-release
on:
release:
types: [published]
jobs:
releasing:
name: releasing
runs-on: ${{ matrix.platform }}
strategy:
fail-fast: true
matrix:
include:
- platform: linux
os: ubuntu-latest
target: x86_64-unknown-linux-gnu
channel: stable
- platform: windows
os: windows-latest
target: x86_64-pc-windows-gnu
channel: stable
- platform: macos
os: macos-latest
target: x86_64-apple-darwin
channel: stable
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
RELEASE_VERSION: ${{ github.event.release.tag_name }}
TARGET_DIR: target/release
ARTIFACT_DIR: target/artifacts
ARTIFACT_NAME: solrcopy-${{ github.event.release.tag_name }}-${{ matrix.target }}
steps:
# region Install and update Rust
- name: Show release version
run: |
echo "github.event.release.tag_name : ${{ github.event.release.tag_name }}"
echo "github.event.release.upload_url : ${{ github.event.release.upload_url }}"
echo "github.event_path : ${{ github.event_path }}"
- name: Install rpm tools
if: matrix.platform == 'linux'
run: |
sudo apt-get update
sudo apt-get install -y --no-install-recommends rpm
- name: Install mingw toolchain
if: matrix.platform == 'windows'
run: |
sudo apt-get update
sudo apt-get install -y --no-install-recommends mingw-w64
- name: Rustup Self Update
if: matrix.platform != 'macos'
run: |
rustup self update
- name: Update Rust toolchain from channel ${{ matrix.channel }}
run: |
rustup update ${{ matrix.channel }}
rustup default ${{ matrix.channel }}
- name: Check Rust ${{ matrix.channel }} toolchain versions
run: |
rustup --version
cargo --version
rustc --version
rustup show
- name: Install cargo plugins
if: matrix.platform == 'linux'
run: cargo install cargo-deb cargo-generate-rpm
# endregion
# region Compiling
- name: Checkout sources
uses: actions/checkout@v4
- name: Create local artifact folders
run: mkdir -p ${{ env.ARTIFACT_DIR }} target/assets
- name: Generate Assets
run: cargo run -- generate --all --output-dir target/assets
- name: Compiling the application for further packaging
run: cargo build --release
# endregion
# region Packaging
- name: Make a tar package for release (linux and macos)
if: matrix.platform == 'linux' || matrix.platform == 'macos'
run: tar --directory=${{ env.TARGET_DIR }} -czvf ${{ env.ARTIFACT_DIR }}/${{ env.ARTIFACT_NAME }}.tar.gz solrcopy
- name: Make a Windows zip package
if: matrix.platform == 'windows'
run: |
ls -lshFGHL ${{ env.TARGET_DIR }}
zip -j ${{ env.ARTIFACT_DIR }}/${{ env.ARTIFACT_NAME }}.zip ${{ env.TARGET_DIR }}/solrcopy.exe
- name: Make the debian package
if: matrix.platform == 'linux'
run: cargo deb --profile release --verbose --no-build --output ${{ env.ARTIFACT_DIR }}/${{ env.ARTIFACT_NAME }}.deb
- name: Make a rpm package
if: matrix.platform == 'linux'
run: cargo generate-rpm --profile release --output ${{ env.ARTIFACT_DIR }}/${{ env.ARTIFACT_NAME }}.rpm
# endregion
# region Upload Artifact
- name: Upload Debian Package
uses: actions/upload-release-asset@v1
if: matrix.platform == 'linux'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ github.event.release.upload_url }}
asset_path: ${{ env.ARTIFACT_DIR }}/${{ env.ARTIFACT_NAME }}.deb
asset_name: ${{ env.ARTIFACT_NAME }}.deb
asset_content_type: application/vnd.debian.binary-package
- name: Upload RPM Package
uses: actions/upload-release-asset@v1
if: matrix.platform == 'linux'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ github.event.release.upload_url }}
asset_path: ${{ env.ARTIFACT_DIR }}/${{ env.ARTIFACT_NAME }}.rpm
asset_name: ${{ env.ARTIFACT_NAME }}.rpm
asset_content_type: application/x-rpm
- name: Upload linux binary package
uses: actions/upload-release-asset@v1
if: matrix.platform == 'linux' || matrix.platform == 'macos'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ github.event.release.upload_url }}
asset_path: ${{ env.ARTIFACT_DIR }}/${{ env.ARTIFACT_NAME }}.tar.gz
asset_name: ${{ env.ARTIFACT_NAME }}.tar.gz
asset_content_type: application/octet-stream
- name: Upload windows binary package
uses: actions/upload-release-asset@v1
if: matrix.platform == 'windows'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ github.event.release.upload_url }}
asset_path: ${{ env.ARTIFACT_DIR }}/${{ env.ARTIFACT_NAME }}.zip
asset_name: ${{ env.ARTIFACT_NAME }}.zip
asset_content_type: application/octet-stream
# endregion
# end of file