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

feat: semver and major releases on merge #300

Merged
merged 29 commits into from
Nov 27, 2024
Merged
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
f948d6b
fix: missing dist folder
DerekRoberts Nov 26, 2024
dd470e0
chore: test
DerekRoberts Nov 26, 2024
68010fc
chore: Test
DerekRoberts Nov 26, 2024
01fee90
fix: release
DerekRoberts Nov 26, 2024
d776ac7
fix: release
DerekRoberts Nov 26, 2024
41e4b83
chore: maybe working
DerekRoberts Nov 26, 2024
efa7870
chore: rearrange jobs
DerekRoberts Nov 26, 2024
e0e1a32
fix: conditionals/needs
DerekRoberts Nov 27, 2024
69eb684
fix: fine tune
DerekRoberts Nov 27, 2024
6767318
Simplify cleanup
DerekRoberts Nov 27, 2024
b6d1c18
feat: push major release
DerekRoberts Nov 27, 2024
c3d2953
feat: push major release
DerekRoberts Nov 27, 2024
92a042d
feat: push major release
DerekRoberts Nov 27, 2024
3fb27ee
feat: push major release
DerekRoberts Nov 27, 2024
380445d
feat: push major release
DerekRoberts Nov 27, 2024
f66bf92
feat: push major release
DerekRoberts Nov 27, 2024
a3c5680
feat: push major release
DerekRoberts Nov 27, 2024
e5935cb
feat: handle existing major release
DerekRoberts Nov 27, 2024
db01ced
feat: fix git user
DerekRoberts Nov 27, 2024
48081c2
feat: handle existing major release
DerekRoberts Nov 27, 2024
c15cb47
feat: semver continue on error
DerekRoberts Nov 27, 2024
32296dc
feat: fix cleanup
DerekRoberts Nov 27, 2024
f24692f
feat: fix cleanup
DerekRoberts Nov 27, 2024
dfa8e2d
feat: major release
DerekRoberts Nov 27, 2024
93fc594
feat: stop tag clobbering
DerekRoberts Nov 27, 2024
619c8e8
feat: clobber major tag
DerekRoberts Nov 27, 2024
ee09f59
feat: generate notes for major release
DerekRoberts Nov 27, 2024
efdb175
Consolidate steps
DerekRoberts Nov 27, 2024
4bf6b52
Restore workflows
DerekRoberts Nov 27, 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
88 changes: 47 additions & 41 deletions .github/workflows/merge.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,64 +19,70 @@ jobs:
release:
name: Release
env:
TEMP_BRANCH: release-${{ github.run_number }}
branch: temp-${{ github.run_number }}
outputs:
tag: ${{ steps.changelog.outputs.tag }}
next: ${{ steps.semver.outputs.next }}
permissions:
contents: write
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0

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

- name: Rebuild and push the dist/ directory
if: ${{ steps.changelog.outputs.tag }}
- name: Git Setup
if: ${{ steps.semver.outputs.next }}
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 checkout -b ${{ env.branch }}

- name: Rebuild ./dist
if: ${{ steps.semver.outputs.next }}
run: |
npm run dist
git add ./dist --force
git commit -m "Rebuild dist/ directory"
git push -u origin HEAD:${{ env.TEMP_BRANCH }}
git push -u origin HEAD:${{ env.branch }}

- name: Release
- name: Tag and Release (Major)
if: ${{ steps.semver.outputs.next }}
env:
GH_TOKEN: ${{ github.token }}
if: ${{ steps.changelog.outputs.tag }}
tag: ${{ steps.semver.outputs.nextMajor }}
run: |
echo "Creating release ${{ steps.changelog.outputs.tag }}"
git push origin tag ${{ steps.changelog.outputs.tag }}
gh release create ${{ steps.changelog.outputs.tag }} --title ${{ steps.changelog.outputs.tag }} --generate-notes
git tag -f ${{ env.tag }}
git push -f origin tag ${{ env.tag }}

cleanup:
name: Cleanup
if: always() && ${{ needs.release.outputs.tag }}
needs: release
env:
TEMP_BRANCH: release-${{ github.run_number }}
permissions:
contents: write
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
if [ $(gh release view ${{ env.tag }} --json name -q .name) ]; then
gh release edit ${{ env.tag }} --title ${{ env.tag }} --tag ${{ env.tag }}
else
gh release create ${{ env.tag }} --title ${{ env.tag }} --generate-notes
fi

- name: Tag and Release (Semver)
if: ${{ steps.semver.outputs.next }}
env:
GH_TOKEN: ${{ github.token }}
tag: ${{ steps.semver.outputs.next }}
run: |
git tag ${{ env.tag }}
git push origin tag ${{ env.tag }}

if [ $(gh release view ${{ env.tag }} --json name -q .name) ]; then
gh release delete ${{ env.tag }} --yes
fi
gh release create ${{ env.tag }} --title ${{ env.tag }} --generate-notes

- name: Cleanup
run: git push --delete origin ${{ env.TEMP_BRANCH }}
if: always()
run: |
if [ "$(git ls-remote origin ${{ env.branch }})" ]; then
git push --delete origin ${{ env.branch }}
else
echo "Cleanup not required"
fi