|
| 1 | +name: Release |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + tags: |
| 6 | + - "v*" |
| 7 | + |
| 8 | +permissions: |
| 9 | + contents: write |
| 10 | + |
| 11 | +jobs: |
| 12 | + test: |
| 13 | + name: "Test before release" |
| 14 | + runs-on: ubuntu-latest |
| 15 | + steps: |
| 16 | + - name: Check out code |
| 17 | + uses: actions/checkout@v4 |
| 18 | + |
| 19 | + - name: Setup Perl |
| 20 | + uses: shogo82148/actions-setup-perl@v1 |
| 21 | + with: |
| 22 | + perl-version: "5.42" |
| 23 | + |
| 24 | + - name: Verify Docker is available |
| 25 | + run: | |
| 26 | + docker version |
| 27 | + docker info |
| 28 | +
|
| 29 | + - name: Install dependencies |
| 30 | + run: | |
| 31 | + cpanm --installdeps . |
| 32 | + cpanm --notest HTTP::Tiny |
| 33 | +
|
| 34 | + - name: Build |
| 35 | + run: perl Build.PL && ./Build |
| 36 | + |
| 37 | + - name: Run unit tests |
| 38 | + run: prove -lv t/01-load.t t/02-container-request.t t/03-wait-strategies.t t/06-basic.t t/07-system.t t/08-version.t t/09-containers.t t/10-images.t t/11-networks.t t/12-volumes.t |
| 39 | + |
| 40 | + - name: Pre-pull Docker images |
| 41 | + run: | |
| 42 | + docker pull nginx:alpine & |
| 43 | + docker pull postgres:16-alpine & |
| 44 | + docker pull redis:7-alpine & |
| 45 | + wait |
| 46 | +
|
| 47 | + - name: Run integration tests |
| 48 | + env: |
| 49 | + TESTCONTAINERS_LIVE: "1" |
| 50 | + run: prove -lv t/04-integration.t t/05-modules.t |
| 51 | + |
| 52 | + - name: Clean up containers |
| 53 | + if: always() |
| 54 | + run: | |
| 55 | + docker ps -a --filter "label=org.testcontainers" -q | xargs -r docker rm -f |
| 56 | + docker system prune -f |
| 57 | +
|
| 58 | + build-dist: |
| 59 | + name: Build distribution |
| 60 | + needs: [test] |
| 61 | + runs-on: ubuntu-latest |
| 62 | + steps: |
| 63 | + - name: Check out code |
| 64 | + uses: actions/checkout@v4 |
| 65 | + |
| 66 | + - name: Setup Perl |
| 67 | + uses: shogo82148/actions-setup-perl@v1 |
| 68 | + with: |
| 69 | + perl-version: "5.42" |
| 70 | + |
| 71 | + - name: Install dependencies |
| 72 | + run: cpanm --installdeps . |
| 73 | + |
| 74 | + - name: Build distribution |
| 75 | + run: | |
| 76 | + perl Build.PL |
| 77 | + ./Build manifest |
| 78 | + ./Build dist |
| 79 | +
|
| 80 | + - name: Verify tarball |
| 81 | + run: | |
| 82 | + ls -la Testcontainers-*.tar.gz |
| 83 | + tar tzf Testcontainers-*.tar.gz | head -20 |
| 84 | +
|
| 85 | + - name: Upload distribution artifact |
| 86 | + uses: actions/upload-artifact@v4 |
| 87 | + with: |
| 88 | + name: cpan-dist |
| 89 | + path: Testcontainers-*.tar.gz |
| 90 | + |
| 91 | + github-release: |
| 92 | + name: Create GitHub Release |
| 93 | + needs: [build-dist] |
| 94 | + runs-on: ubuntu-latest |
| 95 | + steps: |
| 96 | + - name: Check out code |
| 97 | + uses: actions/checkout@v4 |
| 98 | + with: |
| 99 | + fetch-depth: 0 |
| 100 | + |
| 101 | + - name: Download distribution artifact |
| 102 | + uses: actions/download-artifact@v4 |
| 103 | + with: |
| 104 | + name: cpan-dist |
| 105 | + |
| 106 | + - name: Extract version from tag |
| 107 | + id: version |
| 108 | + run: echo "version=${GITHUB_REF_NAME#v}" >> "$GITHUB_OUTPUT" |
| 109 | + |
| 110 | + - name: Create GitHub Release |
| 111 | + uses: softprops/action-gh-release@v2 |
| 112 | + with: |
| 113 | + generate_release_notes: true |
| 114 | + files: Testcontainers-*.tar.gz |
| 115 | + body: | |
| 116 | + ## Installation |
| 117 | +
|
| 118 | + ```bash |
| 119 | + cpanm --installdeps . |
| 120 | + perl Build.PL && ./Build && ./Build install |
| 121 | + ``` |
| 122 | +
|
| 123 | + See [QUICKSTART.md](https://github.com/${{ github.repository }}/blob/${{ github.ref_name }}/QUICKSTART.md) for usage guide. |
| 124 | +
|
| 125 | + publish-cpan: |
| 126 | + name: Publish to CPAN |
| 127 | + needs: [build-dist] |
| 128 | + runs-on: ubuntu-latest |
| 129 | + environment: cpan |
| 130 | + steps: |
| 131 | + - name: Setup Perl |
| 132 | + uses: shogo82148/actions-setup-perl@v1 |
| 133 | + with: |
| 134 | + perl-version: "5.42" |
| 135 | + |
| 136 | + - name: Download distribution artifact |
| 137 | + uses: actions/download-artifact@v4 |
| 138 | + with: |
| 139 | + name: cpan-dist |
| 140 | + |
| 141 | + - name: Install CPAN upload tool |
| 142 | + run: cpanm --notest CPAN::Uploader |
| 143 | + |
| 144 | + - name: Upload to CPAN |
| 145 | + env: |
| 146 | + CPAN_USERNAME: ${{ secrets.CPAN_USERNAME }} |
| 147 | + CPAN_PASSWORD: ${{ secrets.CPAN_PASSWORD }} |
| 148 | + run: cpan-upload --user "$CPAN_USERNAME" --password "$CPAN_PASSWORD" Testcontainers-*.tar.gz |
0 commit comments