.github/workflows/release.yml

4fddc50d6d9f3d82220a4e3264d792d54fc940cf
weechat-matrix-rs/.github/workflows/release.yml history · blame · raw

103 lines · 4041 bytes

  1on: [push, pull_request]
  2
  3name: build-test-release
  4
  5jobs:
  6  publish:
  7    name: Publish for ${{ matrix.os }}
  8    runs-on: ${{ matrix.os }}
  9    strategy:
 10      matrix:
 11        os: [ubuntu-22.04, ubuntu-latest]
 12        include:
 13          - os: ubuntu-22.04
 14            artifact_name: libmatrix.so
 15            asset_name: libmatrix.so-ubuntu-22.04
 16          - os: ubuntu-24.04
 17            artifact_name: libmatrix.so
 18            asset_name: libmatrix.so-ubuntu-24.04
 19          - os: ubuntu-latest # currently 24.04
 20            artifact_name: libmatrix.so
 21            asset_name: libmatrix.so-ubuntu-latest
 22        rust:
 23          - stable
 24      fail-fast: false
 25
 26    steps:
 27      - name: Install latest-stable weechat for Ubuntu
 28        id: build_env
 29        run: |
 30          sudo apt update
 31          sudo apt install dirmngr gpg-agent apt-transport-https
 32          sudo apt-key adv --keyserver hkps://keys.openpgp.org --recv-keys 11E9DE8848F2B65222AA75B8D1820DB22A11534E
 33          echo "deb https://weechat.org/ubuntu $(lsb_release -c | awk '{ print $NF }') main" | sudo tee /etc/apt/sources.list.d/weechat.list
 34          echo "deb-src https://weechat.org/ubuntu $(lsb_release -c | awk '{ print $NF }') main" | sudo tee -a /etc/apt/sources.list.d/weechat.list
 35          sudo apt update
 36          sudo apt install weechat-curses weechat-plugins weechat-python weechat-perl weechat-dev
 37          echo "version of weechat-plugin.h that weechat-sys uses by default:"
 38          grep -m 1 -n -H "WEECHAT_PLUGIN_API_VERSION" "/usr/include/weechat/weechat-plugin.h"
 39          v="$(grep -m 1 -o  'WEECHAT_PLUGIN_API_VERSION.*' '/usr/include/weechat/weechat-plugin.h')"
 40          echo "W_API_V=$v" >> $GITHUB_OUTPUT
 41
 42      - name: Install sqlite3 libraries
 43        run: |
 44          sudo apt install libsqlite3-dev
 45
 46      - name: Checkout sources
 47        uses: actions/checkout@v4
 48
 49      - name: Install toolchain
 50        run: |
 51          rustup update --no-self-update
 52          rustup default stable
 53
 54      - name: Run cargo build
 55        run: cargo build --release
 56
 57      - name: Run cargo test
 58        run: cargo test --release
 59
 60      - name: Upload binary
 61        uses: actions/upload-artifact@v4
 62        with:
 63          name: 'libmatrix.so-${{ matrix.os }}'
 64          path: target/release/libmatrix.so
 65
 66  publish-deb:
 67    name: Publish .deb for Debian 13 (trixie)
 68    runs-on: ubuntu-latest
 69    container:
 70      image: debian:trixie
 71    steps:
 72      - name: Install system dependencies
 73        run: |
 74          apt-get update
 75          apt-get install -y ca-certificates curl gnupg apt-transport-https build-essential pkg-config libssl-dev libsqlite3-dev libclang-dev git
 76          mkdir -p /etc/apt/keyrings
 77          curl --silent https://weechat.org/dev/info/debian_repository_signing_key_asc/ | tee /etc/apt/keyrings/weechat.asc
 78          echo "deb [signed-by=/etc/apt/keyrings/weechat.asc] https://weechat.org/debian trixie main" | tee /etc/apt/sources.list.d/weechat.list
 79          apt-get update
 80          apt-get install -y weechat-curses weechat-plugins weechat-python weechat-perl weechat-dev
 81      - name: Install Rust toolchain
 82        run: |
 83          curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
 84          echo "$HOME/.cargo/bin" >> $GITHUB_PATH
 85          # rustup isn't on PATH yet in this step, use full path
 86          "$HOME/.cargo/bin/rustup" default stable
 87      - name: Checkout sources
 88        uses: actions/checkout@v4
 89      - name: Install cargo-deb
 90        run: cargo install cargo-deb
 91      - name: Build .deb package
 92        run: make deb
 93      - name: Find .deb artifact
 94        id: deb_artifact
 95        run: |
 96          deb_file=$(ls target/debian/weechat-matrix_*.deb)
 97          echo "path=$deb_file" >> "$GITHUB_OUTPUT"
 98          echo "name=$(basename "$deb_file" .deb)" >> "$GITHUB_OUTPUT"
 99      - name: Upload .deb artifact
100        uses: actions/upload-artifact@v4
101        with:
102          name: ${{ steps.deb_artifact.outputs.name }}
103          path: ${{ steps.deb_artifact.outputs.path }}