Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci: release script improvements #808

Draft
wants to merge 1 commit into
base: develop
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
95 changes: 36 additions & 59 deletions .github/workflows/holy-grail.yml
Original file line number Diff line number Diff line change
Expand Up @@ -136,12 +136,13 @@ jobs:
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

#TODO: check if there is anything to commit
- name: Commit and push
run: |
git add .
git commit -m "ci(release-core-step): added bumped version files"
git push --force --no-verify

#TODO: chekc if one below is extra, do we need it?
outputs:
version: ${{ steps.version.outputs.PACKAGE_VERSION }}

Expand Down Expand Up @@ -360,10 +361,11 @@ jobs:
version: ${{ steps.version.outputs.PACKAGE_VERSION }}

#ON FAILURE
#TODO: come back to this, maybe move it all the way down
on-failure:
needs: [create-release-branch, release-core, release-angular, release-angular-17, release-react]
runs-on: ubuntu-latest
if: always() && (needs.create-release-branch.result == 'failure' || needs.release-core.result == 'failure' || needs.release-angular.result == 'failure' || needs.release-angular-17.result == 'failure' || needs.release-react.result == 'failure')
if: (needs.create-release-branch.result == 'failure' || needs.release-core.result == 'failure' || needs.release-angular.result == 'failure' || needs.release-angular-17.result == 'failure' || needs.release-react.result == 'failure')
steps:
- name: Download version
uses: actions/download-artifact@v4
Expand All @@ -372,38 +374,47 @@ jobs:
path: packages/core

- name: Remove branch on failure
run: |
version=$(jq -r .version packages/core/package.json) # extract version from package.json
if [ "${{ job.status }}" == "failure" ] && [ -n "$version" ]; then
git push --no-verify origin --delete @scania/tegel@$version
fi
run: git push --no-verify origin --delete release/tegel@${{ steps.version.outputs.PACKAGE_VERSION }}

#MERGE RELEASE BRANCH TO DEVELOP
merge-release-branch-into-develop:
needs: [create-release-branch, release-core, release-angular, release-angular-17, release-react]
runs-on: ubuntu-latest
if: (needs.create-release-branch.result == 'success' && needs.release-core.result == 'success' && needs.release-angular.result == 'success' && needs.release-angular-17.result == 'success' && needs.release-react.result == 'success')
steps:
- name: Check out code
uses: actions/checkout@v4
with:
ref: develop
ref: release/tegel@${{ steps.version.outputs.PACKAGE_VERSION }}
fetch-depth: 0 # Fetch all branches
token: ${{ secrets.GH_PERSONAL_ACCESS_TOKEN }}

- name: Fetch all branches
run: git fetch --all

- name: Remove git tag on failure
- name: Set up Git for authentication
run: |
tagname="@scania/tegel@${{ needs.release-core.outputs.version }}"
if git rev-parse $tagname >/dev/null 2>&1; then
git push --no-verify --delete origin $tagname
fi
tagname="@scania/tegel-angular@${{ needs.release-angular.outputs.version }}"
if git rev-parse $tagname >/dev/null 2>&1; then
git push --no-verify --delete origin $tagname
fi
tagname="@scania/tegel-angular-17@${{ needs.release-angular-17.outputs.version }}"
if git rev-parse $tagname >/dev/null 2>&1; then
git push --no-verify --delete origin $tagname
git config --global user.name "Tegel - Scania"
git config --global user.email "[email protected]"
git remote set-url origin https://x-access-token:${{ secrets.GH_PERSONAL_ACCESS_TOKEN }}@github.com/${{ github.repository }}

- name: Merge release branch into develop
run: |
git checkout develop
git merge --squash -X theirs release/tegel@${{ steps.version.outputs.PACKAGE_VERSION }}
git add .
if ! git diff-index --quiet HEAD; then
git commit -m "release: tegel ${{ steps.version.outputs.PACKAGE_VERSION }}"
git push --force --no-verify origin develop
else
echo "No changes to commit in develop"
fi
tagname="@scania/tegel-react@${{ needs.release-react.outputs.version }}"
if git rev-parse $tagname >/dev/null 2>&1; then
git push --no-verify --delete origin $tagname

#CREATE GIT TAG
create-git-tag:
needs: merge-release-branch-into-develop
runs-on: ubuntu-latest
if: (needs.merge-release-branch-into-develop.result == 'success')
env:
WORKING_DIRECTORY: packages/core
steps:
Expand Down Expand Up @@ -432,45 +443,11 @@ jobs:
- name: Core - Push git tag
run: git push --no-verify origin @scania/tegel@${{ steps.version.outputs.PACKAGE_VERSION }}

#MERGE RELEASE BRANCH TO DEVELOP
merge-release-branch-into-develop:
needs: create-git-tag
runs-on: ubuntu-latest
if: always()
steps:
- name: Check out code
uses: actions/checkout@v4
with:
ref: release/tegel@${{ steps.version.outputs.PACKAGE_VERSION }}
fetch-depth: 0 # Fetch all branches
token: ${{ secrets.GH_PERSONAL_ACCESS_TOKEN }}

- name: Fetch all branches
run: git fetch --all

- name: Set up Git for authentication
run: |
git config --global user.name "Tegel - Scania"
git config --global user.email "[email protected]"
git remote set-url origin https://x-access-token:${{ secrets.GH_PERSONAL_ACCESS_TOKEN }}@github.com/${{ github.repository }}

- name: Merge release branch into develop
run: |
git checkout develop
git merge --squash -X theirs release/tegel@${{ steps.version.outputs.PACKAGE_VERSION }}
git add .
if ! git diff-index --quiet HEAD; then
git commit -m "release: tegel ${{ steps.version.outputs.PACKAGE_VERSION }}"
git push --force --no-verify origin develop
else
echo "No changes to commit in develop"
fi

#MERGE DEVELOP INTO MAIN
merge-develop-into-main:
needs: merge-release-branch-into-develop
needs: [create-git-tag, merge-release-branch-into-develop]
runs-on: ubuntu-latest
if: always()
if: (needs.create-git-tag.result == 'success' && needs.merge-release-branch-into-develop.result == 'success')
steps:
- name: Check out code
uses: actions/checkout@v4
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/release-all.yml
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,7 @@ jobs:
commit-changes-in-develop:
needs: [release-core, release-angular, release-angular-17, release-react]
runs-on: ubuntu-latest
if: always()
if: (needs.release-core.result == 'success' && needs.release-angular.result == 'success' && needs.release-angular-17.result == 'success' && needs.release-react.result == 'success')
steps:
- name: Check out code
uses: actions/checkout@v4
Expand All @@ -326,7 +326,7 @@ jobs:
merge-develop-into-main:
needs: commit-changes-in-develop
runs-on: ubuntu-latest
if: always()
if: (needs.commit-changes-in-develop.result == 'success')
steps:
- name: Check out code
uses: actions/checkout@v4
Expand Down
Loading