From 8d629451b1c10b4436c0bff14da86115bb530758 Mon Sep 17 00:00:00 2001 From: Brayan batista zuniga Date: Thu, 14 Mar 2024 17:12:39 -0500 Subject: [PATCH] fix: testing skip release env variable 2 --- .github/workflows/template-main.yml | 101 ++++++++++++++-------------- 1 file changed, 50 insertions(+), 51 deletions(-) diff --git a/.github/workflows/template-main.yml b/.github/workflows/template-main.yml index b5f0a21..7d05ee5 100644 --- a/.github/workflows/template-main.yml +++ b/.github/workflows/template-main.yml @@ -3,10 +3,6 @@ name: Release on: push: branches: [ main ] - pull_request: - branches: [ main ] - release: - types: [ created ] permissions: contents: write @@ -27,6 +23,7 @@ jobs: PUBLISH_ARTIFACT: ${{ vars.PUBLISH_ARTIFACT }} DEBUG_MODE: ${{ vars.DEBUG_MODE }} COMMIT_PUSH: ${{ vars.COMMIT_PUSH }} + SKIP_GIT_HOOKS: 'true' SKIP_RELEASE: ${{ contains(github.event.head_commit.message, '[skip release]') }} steps: @@ -36,66 +33,68 @@ jobs: if: ${{ env.DEBUG_MODE == 'true' }} run: | echo "COMMIT_LAST_MESSAGE: ${{ github.event.head_commit.message }}" - echo "validation: ${{ contains(github.event.head_commit.message, '[skip release]') }}" + echo "SKIP_RELEASE: ${{ env.SKIP_RELEASE }}" - # - name: Setup Node.js - # uses: actions/setup-node@v4 - # with: - # node-version: 20.x + - name: Setup Node.js + if: ${{ env.SKIP_RELEASE == 'false' }} + uses: actions/setup-node@v4 + with: + node-version: 20.x - # - name: Set up Elixir 1.14.3 and Otp 25 - # uses: erlef/setup-beam@v1 - # with: - # elixir-version: '1.14.3' - # otp-version: '25' + - name: Set up Elixir 1.14.3 and Otp 25 + if: ${{ env.SKIP_RELEASE == 'false' }} + uses: erlef/setup-beam@v1 + with: + elixir-version: '1.14.3' + otp-version: '25' - # - name: setup semantic-release - # run: npm install -g semantic-release @semantic-release/changelog @semantic-release/github conventional-changelog-eslint conventional-changelog-conventionalcommits conventional-changelog-angular -D + - name: setup semantic-release + if: ${{ env.SKIP_RELEASE == 'false' }} + run: npm install -g semantic-release @semantic-release/changelog @semantic-release/github conventional-changelog-eslint conventional-changelog-conventionalcommits conventional-changelog-angular -D - # - name: release - # run: npx -p conventional-changelog-eslint -p conventional-changelog-conventionalcommits -p @semantic-release/changelog semantic-release + - name: release + if: ${{ env.SKIP_RELEASE == 'false' }} + run: npx -p conventional-changelog-eslint -p conventional-changelog-conventionalcommits -p @semantic-release/changelog semantic-release - # - name: Validate variables - # if: ${{ env.DEBUG_MODE == 'true' }} - # run: | - # echo "RELEASE_VERSION=${{ env.RELEASE_VERSION }}" - # echo "CONDITION RELEASE_VERSION != '';=${{ env.RELEASE_VERSION != '' }}" - # echo "CONDITION PUBLISH_ARTIFACT == '';=${{ env.RELEASE_VERSION == '' }}" - # echo "CONDITION PUBLISH_ARTIFACT == TRUE;=${{ env.PUBLISH_ARTIFACT == 'true' }}" - # echo "CONDITION PUBLISH_ARTIFACT == FALSE;=${{ env.PUBLISH_ARTIFACT == 'false' }}" - # echo "GITHUB_API_URL=${{ env.GITHUB_API_URL }}" - # echo "PUBLISH_ARTIFACT=${{ env.PUBLISH_ARTIFACT }}" - # echo "COMMIT_PUSH=${{ env.COMMIT_PUSH }}" - # echo "DEBUG_MODE=${{ env.DEBUG_MODE }}" + - name: Validate variables + if: ${{ env.SKIP_RELEASE == 'false' && env.DEBUG_MODE == 'true' }} + run: | + echo "RELEASE_VERSION=${{ env.RELEASE_VERSION }}" + echo "CONDITION RELEASE_VERSION != '';=${{ env.RELEASE_VERSION != '' }}" + echo "CONDITION PUBLISH_ARTIFACT == '';=${{ env.RELEASE_VERSION == '' }}" + echo "CONDITION PUBLISH_ARTIFACT == TRUE;=${{ env.PUBLISH_ARTIFACT == 'true' }}" + echo "CONDITION PUBLISH_ARTIFACT == FALSE;=${{ env.PUBLISH_ARTIFACT == 'false' }}" + echo "GITHUB_API_URL=${{ env.GITHUB_API_URL }}" + echo "PUBLISH_ARTIFACT=${{ env.PUBLISH_ARTIFACT }}" + echo "COMMIT_PUSH=${{ env.COMMIT_PUSH }}" + echo "DEBUG_MODE=${{ env.DEBUG_MODE }}" - # - name: Set variables From git tag command - # if: ${{ ( env.PUBLISH_ARTIFACT == 'true' ) || ( env.COMMIT_PUSH == 'true' ) }} - # run: | - # echo "$VER" - # echo "RELEASE_VERSION=$(git tag | sort --version-sort | tail -n1 | tr -d 'v')" >> $GITHUB_ENV + - name: Set variables From git tag command + if: ${{ env.SKIP_RELEASE == 'false' && env.PUBLISH_ARTIFACT == 'true' }} + run: | + echo "$VER" + echo "RELEASE_VERSION=$(git tag | sort --version-sort | tail -n1 | tr -d 'v')" >> $GITHUB_ENV - # - name: Install Mix dependencies - # if: ${{ ( env.PUBLISH_ARTIFACT == 'true' ) }} - # run: mix deps.get && mix deps.compile - # working-directory: Elixir/Konex - # env: - # SKIP_GIT_HOOKS: 'true' + - name: Install Mix dependencies + if: ${{ env.SKIP_RELEASE == 'false' && env.PUBLISH_ARTIFACT == 'true' }} + run: mix deps.get && mix deps.compile + working-directory: Elixir/Konex - # - name: Run Mix tests - # if: ${{ ( env.PUBLISH_ARTIFACT == 'true' ) }} - # run: mix test - # working-directory: Elixir/Konex + - name: Run Mix tests + if: ${{ env.SKIP_RELEASE == 'false' && env.PUBLISH_ARTIFACT == 'true' }} + run: mix test + working-directory: Elixir/Konex - # - name: Upgrade mix.exs - # if: ${{ ( env.COMMIT_PUSH == 'true' ) }} - # run: sed -i 's/@version \".*\"/@version "${{ env.RELEASE_VERSION }}"/g' mix.exs - # working-directory: Elixir/Konex + - name: Upgrade mix.exs + if: ${{ env.SKIP_RELEASE == 'false' && env.COMMIT_PUSH == 'true' }} + run: sed -i 's/@version \".*\"/@version "${{ env.RELEASE_VERSION }}"/g' mix.exs + working-directory: Elixir/Konex # # testing, working but we need to prevent next run. # # adding [skip ci] to commit comment we can skip the new CI run onf the workflow # # not working on multiple commits from pull request # - name: Commit And Push version - # if: ${{ ( env.COMMIT_PUSH == 'true' ) }} + # if: ${{ env.SKIP_RELEASE == 'false' && env.COMMIT_PUSH == 'true' }} # uses: github-actions-x/commit@v2.9 # with: # github-token: ${{ env.GITHUB_TOKEN }} @@ -107,7 +106,7 @@ jobs: # email: bbatist@bancolombia.com.co # - name: Publish to HEX - # if: ${{ ( env.PUBLISH_ARTIFACT == 'true' ) }} + # if: ${{ env.SKIP_RELEASE == 'false' && env.PUBLISH_ARTIFACT == 'true' }} # run: mix hex.publish --replace --yes # working-directory: Elixir/Konex # env: