From 63b63d901d9c291e73724be1459e79584bb0841a Mon Sep 17 00:00:00 2001 From: Carlos Batista <59052959+cbatista8a@users.noreply.github.com> Date: Thu, 4 Jul 2024 19:38:34 +0200 Subject: [PATCH] 19 bug automatic releases dont work properly (#25) * feat: implement separate job for test and build release only if test pass * chore: remove old release builder as is not necessary --- .github/workflows/release_builder.yml | 63 --------------------------- .github/workflows/semver.yml | 59 +++++++++++++++++-------- 2 files changed, 42 insertions(+), 80 deletions(-) delete mode 100644 .github/workflows/release_builder.yml diff --git a/.github/workflows/release_builder.yml b/.github/workflows/release_builder.yml deleted file mode 100644 index 0c66a29..0000000 --- a/.github/workflows/release_builder.yml +++ /dev/null @@ -1,63 +0,0 @@ -name: Release Builder - -on: - create: - tags: - - 'v*' - -permissions: write-all - -jobs: - build: - - runs-on: ubuntu-latest - steps: - - name: Checkout Code - uses: actions/checkout@v3 - - - name: get_changeLog - id: changelog - # Get the history of changes from the last tag to HEAD - run: | - last_tag=$(git describe --tags --abbrev=0) - changelog=$(git log --oneline --pretty=format:"- %s" $last_tag..HEAD) - echo "changelog=$changelog" >> $GITHUB_OUTPUT - echo "tag=$last_tag" >> $GITHUB_OUTPUT - - - name: Cache Composer - uses: actions/cache@v2 - with: - path: ~/.composer/cache - key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} - restore-keys: | - ${{ runner.os }}-composer- - - - name: Install dependencies - run: composer install --prefer-dist --no-progress - - - name: Format Code - run: composer run-script format - - - name: Test Code - run: composer run-script test # replace with check after fix psalm permissions - - - name: Clean Vendor Dev Dependencies - run: | - rm -rf ./vendor - composer install --no-dev - - - - name: Create Zip - run: | - mkdir .flexi - cp -r * .flexi - mv .flexi flexi - zip -r flexi.zip flexi - - - name: Build Artifact - uses: ncipollo/release-action@v1.12.0 - with: - artifacts: ./flexi.zip - allowUpdates: true - name: Release ${{ steps.changelog.outputs.tag }} - body: ${{ steps.changelog.outputs.changelog }} \ No newline at end of file diff --git a/.github/workflows/semver.yml b/.github/workflows/semver.yml index 6133252..070b6a5 100644 --- a/.github/workflows/semver.yml +++ b/.github/workflows/semver.yml @@ -5,36 +5,61 @@ on: - main permissions: - contents: write + contents: read jobs: + tests: + name: Tests + runs-on: ubuntu-latest + + steps: + - name: Checkout repository + uses: actions/checkout@v3 + + - name: Setup PHP + uses: shivammathur/setup-php@v2 + with: + php-version: '7.4' + + - name: Install dependencies + run: composer install --prefer-dist --no-progress + + - name: Run tests + run: composer run-script test + + # run this job only if the tests pass + release: + if: ${{ job.tests.outcome == 'success' }} name: Release runs-on: ubuntu-latest + permissions: + contents: write # to be able to create releases + issues: write # to be able to comment on released issues + pull-requests: write # to be able to comment on released pull requests steps: - name: Checkout repository uses: actions/checkout@v3 - # - name: Setup Git user - # run: | - # git config --global user.name "github-actions[bot]" - # git config --global user.email "github-actions[bot]@users.noreply.github.com" + - name: Setup PHP + uses: shivammathur/setup-php@v2 + with: + php-version: '7.4' + + - name: Install dependencies + run: composer install --prefer-dist --no-progress + + - name: Format Code + run: composer run-script format + + - name: Clean Dev Dependencies + run: | + rm -rf ./vendor + composer install --no-dev - name: Release id: semver uses: huggingface/semver-release-action@latest env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - - name: Create GitHub Release - if: steps.semver.outputs.released == 'true' - uses: actions/create-release@v1 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - tag_name: ${{ steps.semver.outputs.tag }} - release_name: "Flexi Framework ${{ steps.semver.outputs.version }}" - body: "Changelog: ${{ steps.semver.outputs.changelog }}" - draft: false - prerelease: false