ideasonpurpose/wp-svg-lib

View on GitHub
.github/workflows/release-from-version-tag.yml

Summary

Maintainability
Test Coverage
name: Create Release from Version Tags

on:
  push:
    tags: ["v*"]

jobs:
  build:
    runs-on: ubuntu-22.04
    name: Build Release

    steps:
      # https://github.com/marketplace/actions/checkout
      - uses: actions/checkout@v4

      - name: Set up REPO and TAG environment vars
        run: |
          echo "REPO=${GITHUB_REPOSITORY#*/}" >> $GITHUB_ENV
          echo "TAG=${GITHUB_SHA:0:6}" >> $GITHUB_ENV

      - name: This run was triggered by a version tag, reset the $TAG variable to the tag name
        if: startsWith(github.ref, 'refs/tags/v')
        run: |
          echo "TAG=${GITHUB_REF#refs/tags/v}" >> $GITHUB_ENV

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

      - name: Install PHP dependencies
        run: composer install --prefer-dist --no-progress --no-suggest

      - name: Create Zip archive with `composer archive`
        run: |
          composer archive -f zip --dir=../ --file=${REPO}

      - name: Create GitHub release
        if: ${{ contains(github.ref, 'refs/tags/') }}
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
        run: |
          gh release create v${TAG} ../${REPO}.zip