|
| 1 | +name: Release |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + tags: |
| 6 | + - "v*" |
| 7 | + branches: |
| 8 | + - feature/automated-release |
| 9 | + |
| 10 | +permissions: |
| 11 | + contents: write |
| 12 | + |
| 13 | +jobs: |
| 14 | + release: |
| 15 | + runs-on: ubuntu-latest |
| 16 | + |
| 17 | + steps: |
| 18 | + - name: Check out repository code |
| 19 | + uses: actions/checkout@v4 |
| 20 | + with: |
| 21 | + fetch-depth: 0 |
| 22 | + |
| 23 | + - name: Setup Go |
| 24 | + uses: actions/setup-go@v6 |
| 25 | + with: |
| 26 | + go-version-file: ./go.mod |
| 27 | + |
| 28 | + - name: Setup PHP |
| 29 | + uses: shivammathur/setup-php@v2 |
| 30 | + with: |
| 31 | + php-version: "8.4" |
| 32 | + extensions: curl, openssl, phar, zlib |
| 33 | + tools: composer:v2 |
| 34 | + |
| 35 | + - name: Get Composer cache directory |
| 36 | + id: composer-cache |
| 37 | + run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT |
| 38 | + |
| 39 | + - name: Cache Composer dependencies |
| 40 | + uses: actions/cache@v4 |
| 41 | + with: |
| 42 | + path: ${{ steps.composer-cache.outputs.dir }} |
| 43 | + key: ${{ runner.os }}-composer-${{ hashFiles('legacy/composer.lock') }} |
| 44 | + restore-keys: ${{ runner.os }}-composer- |
| 45 | + |
| 46 | + - name: Install legacy dependencies |
| 47 | + run: cd legacy && composer install --no-interaction |
| 48 | + |
| 49 | + - name: Get PHP version from Makefile |
| 50 | + id: php-version |
| 51 | + run: echo "version=$(grep '^PHP_VERSION' Makefile | cut -d= -f2 | tr -d ' ')" >> $GITHUB_OUTPUT |
| 52 | + |
| 53 | + - name: Cache PHP binaries |
| 54 | + uses: actions/cache@v4 |
| 55 | + id: php-cache |
| 56 | + with: |
| 57 | + path: internal/legacy/archives/php_* |
| 58 | + key: php-binaries-${{ steps.php-version.outputs.version }} |
| 59 | + |
| 60 | + - name: Download all PHP binaries |
| 61 | + if: steps.php-cache.outputs.cache-hit != 'true' |
| 62 | + run: make download-php |
| 63 | + |
| 64 | + - name: Write signing keys to files |
| 65 | + run: | |
| 66 | + echo "${{ secrets.RSA_SIGNING_KEY }}" > /tmp/rsa-signing-key.pem |
| 67 | + openssl rsa -in /tmp/rsa-signing-key.pem -pubout -out /tmp/rsa-signing-key.pub |
| 68 | + echo "${{ secrets.GPG_SIGNING_KEY }}" | base64 -d > /tmp/gpg-signing-key.asc |
| 69 | +
|
| 70 | + - name: Build release (tag) |
| 71 | + if: startsWith(github.ref, 'refs/tags/') |
| 72 | + env: |
| 73 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 74 | + NFPM_RSA_SIGNING_KEY_FILE: /tmp/rsa-signing-key.pem |
| 75 | + NFPM_GPG_SIGNING_KEY_FILE: /tmp/gpg-signing-key.asc |
| 76 | + CLOUDSMITH_API_KEY: ${{ secrets.CLOUDSMITH_API_KEY }} |
| 77 | + run: make release |
| 78 | + |
| 79 | + - name: Build snapshot (branch) |
| 80 | + if: "!startsWith(github.ref, 'refs/tags/')" |
| 81 | + env: |
| 82 | + NFPM_RSA_SIGNING_KEY_FILE: /tmp/rsa-signing-key.pem |
| 83 | + NFPM_GPG_SIGNING_KEY_FILE: /tmp/gpg-signing-key.asc |
| 84 | + run: make snapshot |
| 85 | + |
| 86 | + - name: Install repogen |
| 87 | + run: go install github.com/ralt/repogen/cmd/repogen@latest |
| 88 | + |
| 89 | + - name: Configure AWS credentials |
| 90 | + uses: aws-actions/configure-aws-credentials@v4 |
| 91 | + with: |
| 92 | + aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} |
| 93 | + aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} |
| 94 | + aws-region: eu-west-1 |
| 95 | + |
| 96 | + - name: Upload packages to repository |
| 97 | + env: |
| 98 | + GPG_PRIVATE_KEY_FILE: /tmp/gpg-signing-key.asc |
| 99 | + RSA_PRIVATE_KEY_FILE: /tmp/rsa-signing-key.pem |
| 100 | + RSA_PUBLIC_KEY_FILE: /tmp/rsa-signing-key.pub |
| 101 | + run: bash ./repogen.sh |
| 102 | + |
| 103 | + - name: Clean up signing keys |
| 104 | + if: always() |
| 105 | + run: rm -f /tmp/rsa-signing-key.pem /tmp/rsa-signing-key.pub /tmp/gpg-signing-key.asc |
0 commit comments