|
| 1 | +name: Deployment |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + tags: |
| 6 | + - "v*" |
| 7 | + |
| 8 | +jobs: |
| 9 | + secrets: |
| 10 | + name: Secrets |
| 11 | + needs: context |
| 12 | + environment: dockerhub-torrust |
| 13 | + if: needs.context.outputs.continue == 'true' |
| 14 | + runs-on: ubuntu-latest |
| 15 | + |
| 16 | + outputs: |
| 17 | + continue: ${{ steps.check.outputs.continue }} |
| 18 | + |
| 19 | + steps: |
| 20 | + - id: check |
| 21 | + name: Check |
| 22 | + env: |
| 23 | + CRATES_TOKEN: "${{ secrets.CRATES_TOKEN }}" |
| 24 | + if: "${{ env.CRATES_TOKEN != '' }}" |
| 25 | + run: echo "continue=true" >> $GITHUB_OUTPUT |
| 26 | + |
| 27 | + test: |
| 28 | + name: Test |
| 29 | + needs: secrets |
| 30 | + if: needs.secrets.outputs.continue == 'true' |
| 31 | + runs-on: ubuntu-latest |
| 32 | + |
| 33 | + strategy: |
| 34 | + matrix: |
| 35 | + toolchain: [stable, nightly] |
| 36 | + |
| 37 | + steps: |
| 38 | + - id: checkout |
| 39 | + name: Checkout Repository |
| 40 | + uses: actions/checkout@v3 |
| 41 | + |
| 42 | + - id: setup |
| 43 | + name: Setup Toolchain |
| 44 | + uses: dtolnay/rust-toolchain@stable |
| 45 | + with: |
| 46 | + toolchain: ${{ matrix.toolchain }} |
| 47 | + |
| 48 | + - id: test |
| 49 | + name: Run Unit Tests |
| 50 | + run: cargo test --tests --benches --examples --workspace --all-targets --all-features |
| 51 | + |
| 52 | + publish: |
| 53 | + name: Publish |
| 54 | + environment: crates-io-torrust |
| 55 | + needs: test |
| 56 | + if: needs.secrets.outputs.continue == 'true' |
| 57 | + runs-on: ubuntu-latest |
| 58 | + |
| 59 | + steps: |
| 60 | + - id: checkout |
| 61 | + name: Checkout Repository |
| 62 | + uses: actions/checkout@v3 |
| 63 | + |
| 64 | + - id: setup |
| 65 | + name: Setup Toolchain |
| 66 | + uses: dtolnay/rust-toolchain@stable |
| 67 | + with: |
| 68 | + toolchain: stable |
| 69 | + |
| 70 | + env: |
| 71 | + CARGO_REGISTRY_TOKEN: ${{ secrets.CRATES_TOKEN }} |
| 72 | + |
| 73 | + - id: publish |
| 74 | + name: Publish Crates |
| 75 | + run: | |
| 76 | + cargo publish -p torrust-tracker-contrib-bencode |
| 77 | + cargo publish -p torrust-tracker-located-error |
| 78 | + cargo publish -p torrust-tracker-primitives |
| 79 | + cargo publish -p torrust-tracker-configuration |
| 80 | + cargo publish -p torrust-tracker-test-helpers |
| 81 | + cargo publish -p torrust-tracker |
0 commit comments