|
| 1 | +on: |
| 2 | + push: |
| 3 | + branches: |
| 4 | + - main |
| 5 | + |
| 6 | +jobs: |
| 7 | + test: |
| 8 | + runs-on: ubuntu-latest |
| 9 | + env: |
| 10 | + CARGO_TERM_COLOR: always |
| 11 | + steps: |
| 12 | + - uses: actions/checkout@v2 |
| 13 | + - uses: actions-rs/toolchain@v1 |
| 14 | + with: |
| 15 | + profile: minimal |
| 16 | + toolchain: stable |
| 17 | + - name: Run databases |
| 18 | + working-directory: ./tests |
| 19 | + run: docker-compose up -d |
| 20 | + - name: Wait for databases to start |
| 21 | + run: sleep 15s |
| 22 | + shell: bash |
| 23 | + - uses: Swatinem/rust-cache@v1 |
| 24 | + - name: Run tests |
| 25 | + run: cargo test |
| 26 | + |
| 27 | + tag: |
| 28 | + needs: test |
| 29 | + runs-on: ubuntu-latest |
| 30 | + steps: |
| 31 | + - uses: actions/checkout@v2 |
| 32 | + - name: Determine tag |
| 33 | + id: tag |
| 34 | + run: echo "::set-output name=release_tag::v$(grep -m 1 'version' Cargo.toml | awk '{print $3}' | tr -d '/"')" |
| 35 | + outputs: |
| 36 | + release_tag: ${{ steps.tag.outputs.release_tag }} |
| 37 | + |
| 38 | + build: |
| 39 | + needs: tag |
| 40 | + name: Build ${{ matrix.target }} |
| 41 | + runs-on: ubuntu-latest |
| 42 | + strategy: |
| 43 | + fail-fast: false |
| 44 | + matrix: |
| 45 | + include: |
| 46 | + - target: x86_64-pc-windows-gnu |
| 47 | + archive: zip |
| 48 | + name: ${{ github.event.repository.name }}_${{ needs.tag.outputs.release_tag }}_x86_64-pc-windows-gnu |
| 49 | + - target: x86_64-unknown-linux-musl |
| 50 | + archive: tar.gz tar.xz |
| 51 | + name: ${{ github.event.repository.name }}_${{ needs.tag.outputs.release_tag }}_x86_64-unknown-linux-musl |
| 52 | + - target: x86_64-apple-darwin |
| 53 | + archive: zip |
| 54 | + name: ${{ github.event.repository.name }}_${{ needs.tag.outputs.release_tag }}_x86_64-apple-darwin |
| 55 | + steps: |
| 56 | + - uses: actions/checkout@master |
| 57 | + - name: Compile builds |
| 58 | + id: compile |
| 59 | + uses: rust-build/rust-build.action@v1.3.2 |
| 60 | + with: |
| 61 | + RUSTTARGET: ${{ matrix.target }} |
| 62 | + ARCHIVE_TYPES: ${{ matrix.archive }} |
| 63 | + ARCHIVE_NAME: ${{ matrix.name }} |
| 64 | + UPLOAD_MODE: none |
| 65 | + - name: Upload artifact |
| 66 | + uses: actions/upload-artifact@v3 |
| 67 | + with: |
| 68 | + name: torrust-index-backend |
| 69 | + path: | |
| 70 | + ${{ steps.compile.outputs.BUILT_ARCHIVE }} |
| 71 | + ${{ steps.compile.outputs.BUILT_CHECKSUM }} |
| 72 | +
|
| 73 | + release: |
| 74 | + needs: [tag, build] |
| 75 | + runs-on: ubuntu-latest |
| 76 | + steps: |
| 77 | + - uses: actions/checkout@v2 |
| 78 | + - name: Download builds |
| 79 | + uses: actions/download-artifact@v2 |
| 80 | + with: |
| 81 | + name: torrust-index-backend |
| 82 | + path: torrust-index-backend |
| 83 | + - name: Release |
| 84 | + uses: softprops/action-gh-release@v1 |
| 85 | + with: |
| 86 | + generate_release_notes: true |
| 87 | + tag_name: ${{ needs.tag.outputs.release_tag }} |
| 88 | + files: | |
| 89 | + torrust-index-backend/* |
| 90 | + LICENSE |
0 commit comments