Skip to content
Snippets Groups Projects
build-release.yml 1.8 KiB
Newer Older
---

name: Build release

on:  # yamllint disable-line rule:truthy
  push:
    tags:
      - '*'

jobs:
  build:
    name: Build release
    runs-on: [ubuntu-latest]
    steps:
      - name: Setup PHP, with composer and extensions
        id: setup-php
        # https://github.com/shivammathur/setup-php
        uses: shivammathur/setup-php@v2
        with:
          php-version: '8.0'
          tools: composer:v2
          extensions: mbstring, xml

      - name: Setup problem matchers for PHP
        run: echo "::add-matcher::${{ runner.tool_cache }}/php.json"

Tim van Dijen's avatar
Tim van Dijen committed
      # Store the version, stripping any v-prefix
      - name: Write release version
        run: |
          TAG=${{ github.ref_name }}
          echo "VERSION=${TAG#v}" >> $GITHUB_ENV

      - uses: actions/checkout@v3

      - name: Validate composer.json and composer.lock
        run: composer validate

      - name: Set version in composer.json
Tim van Dijen's avatar
Tim van Dijen committed
        run: composer config version "$VERSION"

      - name: Install Composer dependencies
        run: composer install --no-progress --no-dev --prefer-dist --optimize-autoloader

      - name: Clean release
        run: |
Tim van Dijen's avatar
Tim van Dijen committed
          grep export-ignore .gitattributes | cut -d ' ' -f 1 | while IFS= read -r line
Tim van Dijen's avatar
Tim van Dijen committed
            rm -rf "$line"
          done
          rm -rf .git

      - name: Build tarball
        run: |
          cd ..
Tim van Dijen's avatar
Tim van Dijen committed
          cp -R  simplesamlphp "simplesamlphp-$VERSION"
          tar --owner 0 --group 0 -cvzf "/tmp/simplesamlphp-$VERSION.tar.gz" \
          "simplesamlphp-$VERSION"

      - name: Save tarball
        uses: actions/upload-artifact@v3
        with:
          name: release
Tim van Dijen's avatar
Tim van Dijen committed
          path: "/tmp/simplesamlphp-${{ env.VERSION }}.tar.gz"
          retention-days: 1

      - name: Calculate SHA checksum
Tim van Dijen's avatar
Tim van Dijen committed
        run: sha256sum "/tmp/simplesamlphp-$VERSION.tar.gz"