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

fix(ci): auto releasing w/ dist from temp branch #288

Merged
merged 36 commits into from
Sep 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
f025f0e
fix(ci): use temporary release branch
DerekRoberts Sep 12, 2024
e4f2ed0
Fix workflow
DerekRoberts Sep 12, 2024
720586a
Test w/ dist
DerekRoberts Sep 12, 2024
0840d02
Mostly restore test workflow
DerekRoberts Sep 12, 2024
0c0b96e
.github/workflows/test.yml -> .github/workflows/pr-open.yml
DerekRoberts Sep 12, 2024
6b25b36
Temporarily disable PR workflow
DerekRoberts Sep 12, 2024
6516362
Script release branch creation
DerekRoberts Sep 13, 2024
a27cf54
Delete temp branch
DerekRoberts Sep 13, 2024
5c957cd
Test
DerekRoberts Sep 13, 2024
c51b19b
Test w/o condition
DerekRoberts Sep 13, 2024
00fdb72
Test
DerekRoberts Sep 13, 2024
a412689
Remove dist
DerekRoberts Sep 13, 2024
dea0213
add dist to .gitignore
DerekRoberts Sep 13, 2024
e095f09
Force add ./dist
DerekRoberts Sep 13, 2024
6400d00
Token
DerekRoberts Sep 13, 2024
0269fcf
Try git worktree prune
DerekRoberts Sep 13, 2024
970ea46
Fix not on branch
DerekRoberts Sep 13, 2024
010f38c
Try dropping checkout head_ref
DerekRoberts Sep 13, 2024
ba0c8a7
Changelog
DerekRoberts Sep 16, 2024
e10a1ba
Handle branch and dist before changelog
DerekRoberts Sep 16, 2024
704e46f
Work on changelog push
DerekRoberts Sep 16, 2024
08a62e6
Try release
DerekRoberts Sep 16, 2024
dae39b7
Simplify and test
DerekRoberts Sep 16, 2024
f36e39e
Changelog git-branch
DerekRoberts Sep 17, 2024
55138e6
Move cleanup to always() job
DerekRoberts Sep 17, 2024
dc030a7
Needs/prereqs
DerekRoberts Sep 17, 2024
f35aa2c
Fail if changelog action fails
DerekRoberts Sep 17, 2024
4709876
Fail if changelog action fails
DerekRoberts Sep 17, 2024
b8a2e00
Revise no tag error
DerekRoberts Sep 17, 2024
9e61e09
Branch cleanup
DerekRoberts Sep 17, 2024
2c9bc4f
Delete branch
DerekRoberts Sep 17, 2024
708a9a3
Add origin
DerekRoberts Sep 17, 2024
88777c8
Simplify
DerekRoberts Sep 17, 2024
167fc70
Simplify
DerekRoberts Sep 17, 2024
fba202f
Restore cut envar
DerekRoberts Sep 17, 2024
901b9c1
Cleanup and restore workflows
DerekRoberts Sep 17, 2024
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
75 changes: 45 additions & 30 deletions .github/workflows/merge.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,58 +10,73 @@ on:
- 'tsconfig.json'
- 'action.yml'
workflow_dispatch:
pull_request:

concurrency:
group: ${{ github.workflow }}
cancel-in-progress: true

jobs:
semantic-release:
runs-on: ubuntu-22.04
outputs:
tag: ${{ steps.changelog.outputs.tag }}
version: ${{ steps.changelog.outputs.version }}
release:
name: Release
env:
TEMP_BRANCH: release-${{ github.run_number }}
permissions:
contents: write
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0

- uses: actions/setup-node@v4.0.3
with:
node-version: 20.x

- name: Rebuild the dist/ directory
run: npm run dist
- name: Rebuild and push the dist/ directory
run: |
npm run dist
git diff ./dist
git checkout -b ${{ env.TEMP_BRANCH }}
git add ./dist --force
git config --global user.email "${GITHUB_ACTOR}@users.noreply.github.com"
git config --global user.name "${GITHUB_ACTOR}"
git add .
git commit -m "Rebuild dist/ directory"
git push -u origin HEAD:${{ env.TEMP_BRANCH }}

- name: Conventional Changelog Update
uses: TriPSs/conventional-changelog-action@v5
id: changelog
continue-on-error: true
with:
git-branch: ${{ env.TEMP_BRANCH }}
github-token: ${{ github.token }}
output-file: 'CHANGELOG.md'
skip-version-file: 'true'
skip-commit: 'true'
skip-on-empty: 'false'
git-push: 'true'

# Commit any changes to dist/ and lib/
- uses: EndBug/add-and-commit@v9
with:
add: 'dist/ lib/ --force'
message: "Rebuild dist/ directory"
push: false
skip-on-empty: 'true'

- name: Create Release
uses: softprops/action-gh-release@v2
if: ${{ steps.changelog.outputs.version != '' }}
continue-on-error: true
- name: Release
env:
GITHUB_TOKEN: ${{ github.token }}
GH_TOKEN: ${{ github.token }}
run: |
if [ -z "${{ steps.changelog.outputs.tag }}" ]; then
echo "No tag found, exiting"
exit 1
else
echo "Creating release ${{ steps.changelog.outputs.tag }}"
gh release create ${{ steps.changelog.outputs.tag }} --title ${{ steps.changelog.outputs.tag }} --generate-notes
fi

cleanup:
name: Cleanup
if: always()
needs: release
env:
TEMP_BRANCH: release-${{ github.run_number }}
permissions:
contents: write
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
token: ${{ github.token }}
tag_name: ${{ steps.changelog.outputs.tag }}
name: ${{ steps.changelog.outputs.tag }}
body: ${{ steps.changelog.outputs.clean_changelog }}
fetch-depth: 0

- name: Cleanup
run: git push --delete origin ${{ env.TEMP_BRANCH }}
File renamed without changes.
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# Auto-generated dist
dist

# Dependency directory
node_modules

Expand Down Expand Up @@ -96,4 +99,4 @@ Thumbs.db

# Ignore built ts files
__tests__/runner/*
lib/**/*
lib/**/*
Loading