|
| 1 | +name: Release |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + tags: |
| 6 | + - 'v*.*.*' |
| 7 | + |
| 8 | +permissions: |
| 9 | + contents: write |
| 10 | + |
| 11 | +jobs: |
| 12 | + release: |
| 13 | + name: Build and publish release |
| 14 | + runs-on: ubuntu-latest |
| 15 | + steps: |
| 16 | + - uses: actions/checkout@v4 |
| 17 | + with: |
| 18 | + fetch-depth: 0 |
| 19 | + |
| 20 | + - name: Determine version |
| 21 | + id: version |
| 22 | + run: | |
| 23 | + tag="${GITHUB_REF#refs/tags/}" |
| 24 | + version="${tag#v}" |
| 25 | + echo "tag=$tag" >> "$GITHUB_OUTPUT" |
| 26 | + echo "version=$version" >> "$GITHUB_OUTPUT" |
| 27 | + case "$version" in |
| 28 | + *-*) echo "prerelease=true" >> "$GITHUB_OUTPUT" ;; |
| 29 | + *) echo "prerelease=false" >> "$GITHUB_OUTPUT" ;; |
| 30 | + esac |
| 31 | +
|
| 32 | + - name: Set up PHP |
| 33 | + uses: shivammathur/setup-php@v2 |
| 34 | + with: |
| 35 | + php-version: '8.3' |
| 36 | + coverage: none |
| 37 | + tools: composer:v2 |
| 38 | + extensions: imap, intl, mbstring |
| 39 | + |
| 40 | + - name: Install dependencies |
| 41 | + uses: ramsey/composer-install@v3 |
| 42 | + |
| 43 | + - name: Run unit tests (release safety gate) |
| 44 | + run: composer test:unit -- --colors=never |
| 45 | + |
| 46 | + - name: Build release artifacts |
| 47 | + env: |
| 48 | + VERSION: ${{ steps.version.outputs.version }} |
| 49 | + run: | |
| 50 | + set -euo pipefail |
| 51 | + mkdir -p dist-release |
| 52 | + # The .gitattributes export-ignore directives strip dist/, tests/, |
| 53 | + # .github/, phpunit*.xml.dist, .gitignore, .gitattributes from the |
| 54 | + # archive automatically. The --prefix=imapsync/ wrapper lets users |
| 55 | + # extract straight into Roundcube's plugins/ directory. |
| 56 | + git archive --format=tar.gz --prefix=imapsync/ \ |
| 57 | + -o "dist-release/roundcube-imapsync-${VERSION}.tar.gz" HEAD |
| 58 | + git archive --format=zip --prefix=imapsync/ \ |
| 59 | + -o "dist-release/roundcube-imapsync-${VERSION}.zip" HEAD |
| 60 | +
|
| 61 | + - name: Inspect archive contents |
| 62 | + env: |
| 63 | + VERSION: ${{ steps.version.outputs.version }} |
| 64 | + run: | |
| 65 | + set -euo pipefail |
| 66 | + tarball="dist-release/roundcube-imapsync-${VERSION}.tar.gz" |
| 67 | + # Materialise the listing once so subsequent greps don't trigger |
| 68 | + # SIGPIPE on `tar` under `set -o pipefail` (e.g. `grep -q` closing |
| 69 | + # the pipe after the first match). |
| 70 | + listing="$(mktemp)" |
| 71 | + trap 'rm -f "$listing"' EXIT |
| 72 | + tar -tzf "$tarball" | sort > "$listing" |
| 73 | +
|
| 74 | + echo "=== tarball top-level layout ===" |
| 75 | + head -40 "$listing" |
| 76 | + echo |
| 77 | + echo "=== archive sanity ===" |
| 78 | + # Must contain plugin entry; must NOT contain dev-only paths. |
| 79 | + grep -q '^imapsync/imapsync\.php$' "$listing" |
| 80 | + if grep -E '^imapsync/(tests|dist|\.github|\.gitignore|\.gitattributes|phpunit)' "$listing"; then |
| 81 | + echo "Archive leaks dev-only paths" |
| 82 | + exit 1 |
| 83 | + fi |
| 84 | + echo "OK" |
| 85 | +
|
| 86 | + - name: Generate SHA-256 checksums |
| 87 | + env: |
| 88 | + VERSION: ${{ steps.version.outputs.version }} |
| 89 | + run: | |
| 90 | + set -euo pipefail |
| 91 | + cd dist-release |
| 92 | + sha256sum "roundcube-imapsync-${VERSION}.tar.gz" "roundcube-imapsync-${VERSION}.zip" \ |
| 93 | + > "roundcube-imapsync-${VERSION}.sha256" |
| 94 | + cat "roundcube-imapsync-${VERSION}.sha256" |
| 95 | +
|
| 96 | + - name: Create GitHub release |
| 97 | + uses: softprops/action-gh-release@v2 |
| 98 | + with: |
| 99 | + tag_name: ${{ steps.version.outputs.tag }} |
| 100 | + name: ${{ steps.version.outputs.tag }} |
| 101 | + prerelease: ${{ steps.version.outputs.prerelease }} |
| 102 | + generate_release_notes: true |
| 103 | + fail_on_unmatched_files: true |
| 104 | + body: | |
| 105 | + ## Install |
| 106 | +
|
| 107 | + **Drop-in tarball:** |
| 108 | +
|
| 109 | + ```bash |
| 110 | + cd /path/to/roundcubemail/plugins |
| 111 | + curl -L -o imapsync.tar.gz \ |
| 112 | + https://github.com/mittwald/Roundcube-IMAPsync/releases/download/${{ steps.version.outputs.tag }}/roundcube-imapsync-${{ steps.version.outputs.version }}.tar.gz |
| 113 | + tar -xzf imapsync.tar.gz && rm imapsync.tar.gz |
| 114 | + ``` |
| 115 | +
|
| 116 | + Then enable in `config/config.inc.php`: |
| 117 | +
|
| 118 | + ```php |
| 119 | + $config['plugins'][] = 'imapsync'; |
| 120 | + ``` |
| 121 | +
|
| 122 | + **Via Composer (once published on Packagist):** |
| 123 | +
|
| 124 | + ```bash |
| 125 | + composer require mittwald/imapsync:${{ steps.version.outputs.version }} |
| 126 | + ``` |
| 127 | +
|
| 128 | + SHA-256 checksums are attached as `roundcube-imapsync-${{ steps.version.outputs.version }}.sha256`. |
| 129 | +
|
| 130 | + --- |
| 131 | + files: | |
| 132 | + dist-release/roundcube-imapsync-${{ steps.version.outputs.version }}.tar.gz |
| 133 | + dist-release/roundcube-imapsync-${{ steps.version.outputs.version }}.zip |
| 134 | + dist-release/roundcube-imapsync-${{ steps.version.outputs.version }}.sha256 |
0 commit comments