name: Release on: push: branches: [ "main" ] jobs: release: # Set the job to run on the platform specified by the matrix below runs-on: ${{ matrix.runner }} # Define the build matrix for cross-compilation strategy: matrix: include: - name: x86_64-unknown-linux-gnu runner: ubuntu-latest target: x86_64-unknown-linux-gnu command: cross - name: x86_64-unknown-linux-musl runner: ubuntu-latest target: x86_64-unknown-linux-musl command: cross - name: i686-unknown-linux-gnu runner: ubuntu-latest target: i686-unknown-linux-gnu command: cross - name: aarch64-unknown-linux-gnu runner: ubuntu-latest target: aarch64-unknown-linux-gnu command: cross - name: armv7-unknown-linux-gnueabihf runner: ubuntu-latest target: armv7-unknown-linux-gnueabihf command: cross - name: riscv64gc-unknown-linux-gnu runner: ubuntu-latest target: riscv64gc-unknown-linux-gnu command: cross - name: x86_64-unknown-freebsd runner: ubuntu-latest target: x86_64-unknown-freebsd command: cross - name: x86_64-pc-windows-msvc runner: windows-latest target: x86_64-pc-windows-msvc command: cargo - name: i686-pc-windows-msvc runner: windows-latest target: i686-pc-windows-msvc command: cargo - name: aarch64-pc-windows-msvc runner: windows-latest target: aarch64-pc-windows-msvc command: cargo - name: x86_64-apple-darwin runner: macos-latest target: x86_64-apple-darwin command: cargo - name: aarch64-apple-darwin runner: macos-latest target: aarch64-apple-darwin command: cargo # The steps to run for each matrix item steps: - name: Checkout uses: actions/checkout@v3 with: ref: main fetch-depth: 0 - name: Install Rust uses: dtolnay/rust-toolchain@stable with: targets: "${{ matrix.target }}" - name: Setup cache uses: Swatinem/rust-cache@v2 - name: Determine Ferron version shell: bash run: | FERRON_VERSION_CARGO="$(cat ferron/Cargo.toml | grep -E '^version' | sed -E 's|.*"([0-9a-zA-Z.+-]+)"$|\1|g')" FERRON_VERSION_GIT="$(git tag --sort=-committerdate | head -n 1 | sed s/[^0-9a-zA-Z.+-]//g)" if [ "$FERRON_VERSION_CARGO" != "" ]; then echo "Version determined from Cargo.toml file" echo "FERRON_VERSION=$FERRON_VERSION_CARGO" >> $GITHUB_ENV elif [ "$FERRON_VERSION_GIT" != "" ]; then echo "Version determined from the Git tag" echo "FERRON_VERSION=$FERRON_VERSION_GIT" >> $GITHUB_ENV else echo "Can't determine the server version!" 2>&1 exit 1 fi - name: Install Cross if: matrix.command == 'cross' shell: bash run: | curl -L --proto '=https' --tlsv1.2 -sSf https://raw.githubusercontent.com/cargo-bins/cargo-binstall/main/install-from-binstall-release.sh | bash cargo binstall --no-confirm cross - name: Build binaries run: "${{ matrix.command }} build --verbose --locked --release --target ${{ matrix.target }}" - name: Prepare for packaging shell: bash run: | mkdir release find target/${{ matrix.target }}/release -mindepth 1 -maxdepth 1 -type f ! -name "*.*" -o -name "*.exe" -o -name "*.dll" -o -name "*.dylib" -o -name "*.so" | sed -E "s|(.*)|cp -a \1 release|" | bash cp -a ferron-release.yaml release/ferron.yaml cp -a wwwroot release - name: Create a release ZIP archive uses: thedoctor0/zip-release@0.7.5 with: type: "zip" filename: "../ferron.zip" directory: "release" - name: Set up SSH uses: LuisEnMarroquin/setup-ssh-action@v2.0.5 with: ORIGIN: ${{ secrets.SSH_HOSTNAME }} SSHKEY: ${{ secrets.SSH_KEY }} NAME: ferron-servers PORT: ${{ secrets.SSH_PORT }} USER: ${{ secrets.SSH_USERNAME }} - name: Release Ferron on Ferron's servers shell: bash run: | ssh ferron-servers "mkdir -p ferron/${{ env.FERRON_VERSION }} || true" scp ferron.zip ferron-servers:ferron/${{ env.FERRON_VERSION }}/ferron-${{ env.FERRON_VERSION }}-${{ matrix.target }}.zip # The "move-ferron-archive" is a custom command that moves the ZIP archive to be served by the download server ssh ferron-servers "sudo move-ferron-archive ${{ env.FERRON_VERSION }} ${{ matrix.target }}" docs: runs-on: ubuntu-latest steps: - name: Checkout uses: actions/checkout@v3 with: ref: main - name: Install Rust uses: dtolnay/rust-toolchain@stable - name: Setup cache uses: Swatinem/rust-cache@v2 - name: Generate the Rust crate documentation run: "cargo doc --verbose --locked --release" - name: Create the documentation ZIP archive uses: thedoctor0/zip-release@0.7.5 with: type: "zip" filename: "../../ferron-rustdocs.zip" directory: "target/doc" - name: Set up SSH uses: LuisEnMarroquin/setup-ssh-action@v2.0.5 with: ORIGIN: ${{ secrets.SSH_HOSTNAME }} SSHKEY: ${{ secrets.SSH_KEY }} NAME: ferron-servers PORT: ${{ secrets.SSH_PORT }} USER: ${{ secrets.SSH_USERNAME }} - name: Deploy the documentation shell: bash run: | scp ferron-rustdocs.zip ferron-servers:. # The "deploy-ferron-rustdocs" is a custom command that deploys the Ferron's Rust crate documentation ssh ferron-servers "sudo deploy-ferron-rustdocs ferron-rustdocs.zip && rm ferron-rustdocs.zip" docker: runs-on: ubuntu-latest permissions: packages: write contents: read attestations: write id-token: write steps: - name: Checkout uses: actions/checkout@v3 with: ref: main fetch-depth: 0 - name: Log in to Docker Hub uses: docker/login-action@f4ef78c080cd8ba55a85445d5b36e214a81df20a with: username: ${{ secrets.DOCKER_USERNAME }} password: ${{ secrets.DOCKER_PASSWORD }} - name: Determine Ferron version shell: bash run: | FERRON_VERSION_CARGO="$(cat ferron/Cargo.toml | grep -E '^version' | sed -E 's|.*"([0-9a-zA-Z.+-]+)"$|\1|g')" FERRON_VERSION_GIT="$(git tag --sort=-committerdate | head -n 1 | sed s/[^0-9a-zA-Z.+-]//g)" if [ "$FERRON_VERSION_CARGO" != "" ]; then echo "Version determined from Cargo.toml file" echo "FERRON_VERSION=$FERRON_VERSION_CARGO" >> $GITHUB_ENV elif [ "$FERRON_VERSION_GIT" != "" ]; then echo "Version determined from the Git tag" echo "FERRON_VERSION=$FERRON_VERSION_GIT" >> $GITHUB_ENV else echo "Can't determine the server version!" 2>&1 exit 1 fi - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 - name: Build and push Docker image id: push uses: docker/build-push-action@3b5e8027fcad23fda98b2e3ac259d8d67585f671 with: context: . file: ./Dockerfile push: true tags: "ferronserver/ferron:${{ env.FERRON_VERSION }},ferronserver/ferron:latest" - name: Generate artifact attestation uses: actions/attest-build-provenance@v2 with: subject-name: index.docker.io/ferronserver/ferron subject-digest: ${{ steps.push.outputs.digest }} push-to-registry: true