Refactor release workflow to ensure a clean branch
Updated the release workflow to prepare a clean release branch by copying necessary files to a temporary directory and then resetting the branch to avoid residue from previous commits. This ensures only the relevant files are included in the release, enhancing the integrity and clarity of the release branch.
This commit is contained in:
33
.github/workflows/CreateRelease.yml
vendored
33
.github/workflows/CreateRelease.yml
vendored
@@ -90,16 +90,37 @@ jobs:
|
|||||||
git config --local user.email "actions@github.com"
|
git config --local user.email "actions@github.com"
|
||||||
shell: bash
|
shell: bash
|
||||||
|
|
||||||
- name: Create temporary branch
|
- name: Create release commit in the release branch
|
||||||
id: create_temp_branch
|
id: create_release_commit
|
||||||
if: steps.check_version.outputs.skip_release == 'false'
|
if: steps.check_version.outputs.skip_release == 'false'
|
||||||
run: |
|
run: |
|
||||||
git checkout release
|
# Create a temporary directory to save the files
|
||||||
git reset
|
temp_dir=$(mktemp -d)
|
||||||
rm -f .gitignore
|
|
||||||
|
# Copy the files to the temporary directory
|
||||||
|
cp -R README.md package.json LICENSE dist/ src/ tsconfig.json $temp_dir/
|
||||||
|
|
||||||
|
# Checkout the release branch (or create it if it doesn't exist)
|
||||||
|
git fetch origin
|
||||||
|
git checkout -b release origin/release || git checkout --orphan release
|
||||||
|
|
||||||
|
# Remove all files from the working directory
|
||||||
|
git rm -rf .
|
||||||
|
|
||||||
|
# Move the files back from the temporary directory
|
||||||
|
cp -R $temp_dir/* .
|
||||||
|
|
||||||
|
# Clean up the temporary directory
|
||||||
|
rm -rf $temp_dir
|
||||||
|
|
||||||
|
# Add the files to the release branch
|
||||||
git add README.md package.json LICENSE dist/ src/ tsconfig.json
|
git add README.md package.json LICENSE dist/ src/ tsconfig.json
|
||||||
|
|
||||||
|
# Commit the changes
|
||||||
git commit -m "Prepare files for release ${{ env.VERSION }}"
|
git commit -m "Prepare files for release ${{ env.VERSION }}"
|
||||||
git push origin release
|
|
||||||
|
# Push the changes to the release branch
|
||||||
|
git push -u origin release
|
||||||
env:
|
env:
|
||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
shell: bash
|
shell: bash
|
||||||
|
Reference in New Issue
Block a user