Skip to content

Commit

Permalink
ci: fix github release workflows-v2 (#343)
Browse files Browse the repository at this point in the history
ci: fix github release workflows
ci: remove excess condition check
ci: fix the if condition
  • Loading branch information
itsdebs authored Oct 30, 2023
1 parent 94714ab commit 2b47028
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 25 deletions.
28 changes: 9 additions & 19 deletions .github/workflows/publish-new-github-release-v2.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,23 +20,13 @@ jobs:
BRANCH_NAME="${{ github.event.pull_request.head.ref }}"
VERSION=${BRANCH_NAME#hotfix-}
VERSION=${VERSION#release-v2/}
echo "release_version=$VERSION" >> $GITHUB_OUTPUT
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Get the latest version tag v2
id: extract-previous-version-v2
run: |
TAGS=$(git tag --sort=-v:refname)
TAGS_ARRAY=($TAGS)
VERSION=${TAGS_ARRAY[0]}
echo "previous_version=$VERSION" >> $GITHUB_OUTPUT
- name: Setup Node v2
uses: actions/setup-node@v3
with:
Expand All @@ -57,35 +47,35 @@ jobs:
- name: Create Monorepo Release Tag v2
id: create_monorepo_release_v2
run: |
git tag -a v${{ steps.extract-version.outputs.release_version }} -m "chore: release v${{ steps.extract-version.outputs.release_version }}"
git push origin refs/tags/v${{ steps.extract-version.outputs.release_version }}
git tag -a v${{ steps.extract-version-v2.outputs.release_version }} -m "chore: release v${{ steps.extract-version-v2.outputs.release_version }}"
git push origin refs/tags/v${{ steps.extract-version-v2.outputs.release_version }}
- name: Get the two latest versions
run: |
CURRENT_VERSION=$(git tag -l "v*" --sort=-version:refname | head -n 1)
LAST_VERSION=$(git tag -l "v*" --sort=-version:refname | head -n 2 | awk 'NR == 2 { print $1 }')
CURRENT_VERSION=$(git tag -l "v2*" --sort=-version:refname | head -n 1)
LAST_VERSION=$(git tag -l "v2*" --sort=-version:refname | head -n 2 | awk 'NR == 2 { print $1 }')
echo "Current version: $CURRENT_VERSION"
echo "Previous version: $LAST_VERSION"
echo "current_version=$(echo $CURRENT_VERSION)" >> $GITHUB_ENV
echo "last_version=$(echo $LAST_VERSION)" >> $GITHUB_ENV
echo "current_monorepo_version=$(echo $CURRENT_VERSION)" >> $GITHUB_ENV
echo "last_monorepo_version=$(echo $LAST_VERSION)" >> $GITHUB_ENV
echo "DATE=$(date)" >> $GITHUB_ENV
- name: Create GitHub Releases v2
id: create_release_v2
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
npm run release:github -- --base=$last_version --head=$current_version
npm run release:github -- --base=${{ env.last_monorepo_version }} --head=${{ env.current_monorepo_version }}
- name: Create pull request into develop v2
uses: repo-sync/pull-request@v2
with:
source_branch: 'master-v2'
destination_branch: 'develop-v2'
github_token: ${{ secrets.PAT }}
pr_title: 'chore(release): pulling master-v2 into develop-v2 post release v${{ steps.extract-version.outputs.release_version }}'
pr_title: 'chore(release): pulling master-v2 into develop-v2 post release v${{ steps.extract-version-v2.outputs.release_version }}'
pr_body: ':crown: *An automated PR*'
pr_reviewer: 'itsdebs'

Expand Down Expand Up @@ -131,7 +121,7 @@ jobs:
"type": "section",
"text": {
"type": "mrkdwn",
"text": "*Release: <${{env.RELEASES_URL}}${{ steps.extract-previous-version.outputs.previous_version }}...v${{ steps.extract-version.outputs.release_version }}|v${{ steps.extract-version.outputs.release_version }}>*\n${{ env.DATE }}"
"text": "*Release: <${{env.RELEASES_URL}}${{ env.last_monorepo_version }}...v${{steps.extract-version-v2.outputs.release_version }}|v${{ steps.extract-version-v2.outputs.release_version }}>*\n${{ env.DATE }}"
}
}
]
Expand Down
14 changes: 8 additions & 6 deletions .github/workflows/release-v2.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@ on:
- master-v2
types:
- closed
workflow_dispatch:
jobs:
release-v2:
if: (startsWith(github.event.pull_request.head.ref, 'release-v2/') || startsWith(github.event.pull_request.head.ref, 'hotfix-release-v2/')) && github.event.pull_request.merged == true # only merged pull requests must trigger this job
if: (${{ github.event_name == 'workflow_dispatch' }} && startsWith(github.ref, 'refs/heads/master-v2')) || ((startsWith(github.event.pull_request.head.ref, 'release-v2/') || startsWith(github.event.pull_request.head.ref, 'hotfix-release-v2/')) && github.event.pull_request.merged == true) # only merged pull requests must trigger this job
runs-on: ubuntu-latest
environment: deployment
steps:
Expand Down Expand Up @@ -48,19 +49,20 @@ jobs:
- name: Get the two latest versions
run: |
CURRENT_VERSION=$(git tag -l "v*" --sort=-version:refname | head -n 1)
LAST_VERSION=$(git tag -l "v*" --sort=-version:refname | head -n 2 | awk 'NR == 2 { print $1 }')
CURRENT_VERSION=$(git tag -l "v2*" --sort=-version:refname | head -n 1)
LAST_VERSION=$(git tag -l "v2*" --sort=-version:refname | head -n 2 | awk 'NR == 2 { print $1 }')
echo "Current version: $CURRENT_VERSION"
echo "Previous version: $LAST_VERSION"
echo "current_version=$(echo $CURRENT_VERSION)" >> $GITHUB_ENV
echo "last_version=$(echo $LAST_VERSION)" >> $GITHUB_ENV
echo "current_monorepo_version=$(echo $CURRENT_VERSION)" >> $GITHUB_ENV
echo "last_monorepo_version=$(echo $LAST_VERSION)" >> $GITHUB_ENV
echo "DATE=$(date)" >> $GITHUB_ENV
- name: Publish release to sonatype
run: |
git fetch --no-tags --prune --depth=100 origin master-v2
npm run release:sonatype -- --base=$last_version --head=$current_version
npm run release:sonatype -- --base=${{ env.last_monorepo_version }} --head=${{ env.current_monorepo_version }}
env:
SIGNING_KEY_ID: ${{ secrets.SIGNING_KEY_ID }}
Expand Down

0 comments on commit 2b47028

Please sign in to comment.