Merge pull request #305 from Rustmail/298-change-bot-status-with-a-co… #50
Workflow file for this run
This file contains hidden or 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
| name: Release | |
| permissions: | |
| contents: write | |
| packages: write | |
| on: | |
| push: | |
| tags: | |
| - "v*" | |
| env: | |
| CARGO_TERM_COLOR: always | |
| jobs: | |
| build_and_test: | |
| name: Rustmail - latest | |
| runs-on: ubuntu-latest | |
| env: | |
| SQLX_OFFLINE: true | |
| strategy: | |
| matrix: | |
| toolchain: | |
| - stable | |
| - beta | |
| - nightly | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Set up Rust | |
| run: rustup update ${{ matrix.toolchain }} && rustup default ${{ matrix.toolchain }} | |
| - name: Install trunk and wasm target | |
| run: | | |
| rustup target add wasm32-unknown-unknown | |
| cargo install trunk --locked | |
| - name: Install wasm-opt 125 | |
| run: | | |
| wget https://github.com/WebAssembly/binaryen/releases/download/version_125/binaryen-version_125-x86_64-linux.tar.gz | |
| tar -xzf binaryen-version_125-x86_64-linux.tar.gz | |
| sudo mv binaryen-version_125/bin/wasm-opt /usr/local/bin/ | |
| wasm-opt --version | |
| - name: Build frontend | |
| working-directory: rustmail_panel | |
| run: trunk build --release --dist ../rustmail/static --config Trunk.toml | |
| - name: Build Rust backend | |
| run: cargo build --verbose -p rustmail | |
| - name: Run tests | |
| run: cargo test --verbose -p rustmail | |
| create-release: | |
| name: Create Release | |
| needs: build_and_test | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Create release | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GT_TOKEN }} | |
| tag: ${{ github.ref_name }} | |
| run: | | |
| if [[ "$tag" == *alpha* || "$tag" == *beta* ]]; then | |
| prerelease="--prerelease" | |
| else | |
| prerelease="" | |
| fi | |
| gh release create "$tag" \ | |
| --repo="$GITHUB_REPOSITORY" \ | |
| --title="${GITHUB_REPOSITORY#*/} ${tag#v}" \ | |
| --generate-notes $prerelease | |
| upload-assets: | |
| needs: create-release | |
| strategy: | |
| matrix: | |
| include: | |
| - target: x86_64-unknown-linux-gnu | |
| os: ubuntu-latest | |
| - target: x86_64-apple-darwin | |
| os: macos-latest | |
| - target: x86_64-pc-windows-msvc | |
| os: windows-latest | |
| runs-on: ${{ matrix.os }} | |
| env: | |
| SQLX_OFFLINE: true | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Install Rust | |
| run: rustup update stable && rustup default stable | |
| - name: Install trunk and wasm target | |
| run: | | |
| rustup target add wasm32-unknown-unknown | |
| cargo install trunk --locked | |
| - name: Install wasm-opt 125 | |
| run: | | |
| if [ "$RUNNER_OS" == "Linux" ]; then | |
| wget https://github.com/WebAssembly/binaryen/releases/download/version_125/binaryen-version_125-x86_64-linux.tar.gz | |
| tar -xzf binaryen-version_125-x86_64-linux.tar.gz | |
| sudo mv binaryen-version_125/bin/wasm-opt /usr/local/bin/ | |
| elif [ "$RUNNER_OS" == "macOS" ]; then | |
| brew install binaryen | |
| elif [ "$RUNNER_OS" == "Windows" ]; then | |
| curl -L https://github.com/WebAssembly/binaryen/releases/download/version_125/binaryen-version_125-x86_64-windows.tar.gz -o binaryen.tar.gz | |
| tar -xzf binaryen.tar.gz | |
| mv binaryen-version_125/bin/wasm-opt.exe /usr/bin/ | |
| fi | |
| wasm-opt --version | |
| shell: bash | |
| - name: Create static directory | |
| run: mkdir -p rustmail/static | |
| shell: bash | |
| - name: Build frontend | |
| working-directory: rustmail_panel | |
| run: trunk build --release --dist ../rustmail/static --config Trunk.toml | |
| - name: Verify static files were created | |
| run: ls rustmail/static | |
| shell: bash | |
| - uses: taiki-e/upload-rust-binary-action@v1 | |
| with: | |
| bin: rustmail | |
| target: ${{ matrix.target }} | |
| tar: unix | |
| zip: windows | |
| token: ${{ secrets.GT_TOKEN }} | |
| docker-build-push: | |
| name: Build and push Docker Image | |
| needs: upload-assets | |
| runs-on: ubuntu-latest | |
| env: | |
| REGISTRY: ghcr.io | |
| IMAGE_NAME: ${{ github.repository }} | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| - name: Log in to GitHub Container Registry | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: ${{ env.REGISTRY }} | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Download Linux binary from release | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| run: | | |
| rm -rf rustmail | |
| gh release download ${{ github.ref_name }} \ | |
| --repo ${{ github.repository }} \ | |
| --pattern 'rustmail-x86_64-unknown-linux-gnu.tar.gz' | |
| tar -xzf rustmail-x86_64-unknown-linux-gnu.tar.gz | |
| chmod +x rustmail | |
| ls -lh rustmail | |
| - name: Extract metadata for Docker | |
| id: meta | |
| uses: docker/metadata-action@v5 | |
| with: | |
| images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} | |
| tags: | | |
| type=semver,pattern={{version}} | |
| type=semver,pattern={{major}}.{{minor}} | |
| type=semver,pattern={{major}} | |
| type=raw,value=latest,enable=${{ !contains(github.ref, 'alpha') && !contains(github.ref, 'beta') }} | |
| - name: Build and push Docker image | |
| uses: docker/build-push-action@v5 | |
| with: | |
| context: . | |
| push: true | |
| tags: ${{ steps.meta.outputs.tags }} | |
| labels: ${{ steps.meta.outputs.labels }} | |
| platforms: linux/amd64 | |
| cache-from: type=gha | |
| cache-to: type=gha,mode=max |