|
| 1 | +name: release.yml |
| 2 | +on: |
| 3 | + release: |
| 4 | + types: |
| 5 | + - created |
| 6 | + workflow_dispatch: |
| 7 | + |
| 8 | +jobs: |
| 9 | + get-excluded-crates: |
| 10 | + runs-on: ubuntu-latest |
| 11 | + permissions: |
| 12 | + contents: read |
| 13 | + outputs: |
| 14 | + excluded: ${{ steps.excluded-crates.outputs.EXCLUDE }} |
| 15 | + steps: |
| 16 | + - name: Checkout code |
| 17 | + uses: actions/checkout@v5 |
| 18 | + with: |
| 19 | + fetch-tags: true |
| 20 | + |
| 21 | + - name: Get excluded crates |
| 22 | + id: excluded-crates |
| 23 | + run: | |
| 24 | + EXCLUDE=$(./.github/scripts/get-excluded-crates.sh) |
| 25 | + echo "excluding [$EXCLUDE]" |
| 26 | + echo EXCLUDE=$EXCLUDE >> ${GITHUB_OUTPUT} |
| 27 | +
|
| 28 | + publish-crates: |
| 29 | + name: Publish crate librespot-${{ matrix.crate }} |
| 30 | + needs: [ get-excluded-crates ] |
| 31 | + runs-on: ubuntu-latest |
| 32 | + permissions: |
| 33 | + contents: read |
| 34 | + strategy: |
| 35 | + max-parallel: 1 # for sequential execution because the order of publishing the crates is important |
| 36 | + matrix: |
| 37 | + # order is important |
| 38 | + crate: |
| 39 | + - protocol |
| 40 | + - oauth |
| 41 | + - core |
| 42 | + - discovery |
| 43 | + - audio |
| 44 | + - metadata |
| 45 | + - playback |
| 46 | + - connect |
| 47 | + # not all crates needs to be published all the time |
| 48 | + exclude: ${{ fromJSON(needs.get-excluded-crates.outputs.excluded) }} |
| 49 | + steps: |
| 50 | + - name: Checkout code |
| 51 | + uses: actions/checkout@v5 |
| 52 | + |
| 53 | + - name: Install Rust toolchain |
| 54 | + uses: dtolnay/rust-toolchain@stable |
| 55 | + |
| 56 | + - name: Cache Rust dependencies |
| 57 | + uses: Swatinem/rust-cache@v2 |
| 58 | + |
| 59 | + - name: Install dependencies |
| 60 | + if: ${{ contains('connect playback', matrix.crate ) }} # only install the dep when the crate requires it |
| 61 | + run: sudo apt-get update && sudo apt-get install -y libasound2-dev |
| 62 | + |
| 63 | + - name: Verify librespot-${{ matrix.crate }} |
| 64 | + run: cargo publish --package librespot-${{ matrix.crate }} --dry-run |
| 65 | + |
| 66 | + - name: Publish librespot-${{ matrix.crate }} |
| 67 | + if: ${{ !env.ACT }} |
| 68 | + env: |
| 69 | + CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }} |
| 70 | + run: | |
| 71 | + if [ "${{ matrix.crate }}" = "protocol" ]; then |
| 72 | + cargo publish --package librespot-${{ matrix.crate }} --no-verify |
| 73 | + else |
| 74 | + cargo publish --package librespot-${{ matrix.crate }} |
| 75 | + fi |
| 76 | +
|
| 77 | + publish-binary: |
| 78 | + name: publish librespot binary |
| 79 | + needs: [ publish-crates ] |
| 80 | + runs-on: ubuntu-latest |
| 81 | + permissions: |
| 82 | + contents: read |
| 83 | + steps: |
| 84 | + - name: Checkout code |
| 85 | + uses: actions/checkout@v5 |
| 86 | + |
| 87 | + - name: Install Rust toolchain |
| 88 | + uses: dtolnay/rust-toolchain@stable |
| 89 | + |
| 90 | + - name: Cache Rust dependencies |
| 91 | + uses: Swatinem/rust-cache@v2 |
| 92 | + |
| 93 | + - name: Install dependencies |
| 94 | + run: sudo apt-get update && sudo apt-get install -y libasound2-dev |
| 95 | + |
| 96 | + - name: Verify librespot |
| 97 | + run: cargo publish --dry-run --allow-dirty |
| 98 | + |
| 99 | + - name: Publish librespot |
| 100 | + if: ${{ !env.ACT }} |
| 101 | + run: cargo publish --token ${{ secrets.CARGO_REGISTRY_TOKEN }} |
0 commit comments