Skip to content

Commit 2049885

Browse files
authored
Merge pull request #36 from proyecto26/feature/semantic-release
feat(ci): automated release workflow with semantic versioning
2 parents c7b6463 + b8a6a76 commit 2049885

4 files changed

Lines changed: 307 additions & 7 deletions

File tree

.github/FUNDING.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,5 @@ patreon: proyecto26
55
open_collective: proyecto26
66
ko_fi: proyecto26
77
tidelift: "npm/@proyecto26/animatable-component"
8-
liberapay: jdnichollsc
8+
liberapay: proyecto26
99
custom: "https://www.paypal.me/jdnichollsc"

.github/workflows/release.yml

Lines changed: 193 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,193 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
workflow_dispatch:
8+
inputs:
9+
version_bump:
10+
description: 'Version bump type'
11+
required: true
12+
default: 'patch'
13+
type: choice
14+
options:
15+
- patch
16+
- minor
17+
- major
18+
release_notes:
19+
description: 'Additional release notes (optional)'
20+
required: false
21+
type: string
22+
23+
permissions:
24+
contents: write
25+
26+
jobs:
27+
release:
28+
name: Create Release
29+
runs-on: ubuntu-latest
30+
outputs:
31+
new_version: ${{ steps.version.outputs.new_version }}
32+
steps:
33+
- uses: actions/checkout@v4
34+
with:
35+
fetch-depth: 0
36+
token: ${{ secrets.GITHUB_TOKEN }}
37+
38+
- name: Get current version
39+
id: current
40+
run: |
41+
CURRENT=$(node -p "require('./package.json').version")
42+
echo "version=$CURRENT" >> $GITHUB_OUTPUT
43+
echo "Current version: $CURRENT"
44+
45+
- name: Determine version bump from commits
46+
id: bump
47+
run: |
48+
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
49+
echo "type=${{ inputs.version_bump }}" >> $GITHUB_OUTPUT
50+
else
51+
LAST_TAG=$(git describe --tags --abbrev=0 2>/dev/null || echo "")
52+
if [ -z "$LAST_TAG" ]; then RANGE="HEAD"; else RANGE="${LAST_TAG}..HEAD"; fi
53+
COMMITS=$(git log $RANGE --pretty=format:"%s" 2>/dev/null || echo "")
54+
if echo "$COMMITS" | grep -qiE "^(feat|feature)(\(.+\))?!:|BREAKING CHANGE"; then
55+
echo "type=major" >> $GITHUB_OUTPUT
56+
elif echo "$COMMITS" | grep -qiE "^(feat|feature)(\(.+\))?:"; then
57+
echo "type=minor" >> $GITHUB_OUTPUT
58+
else
59+
echo "type=patch" >> $GITHUB_OUTPUT
60+
fi
61+
fi
62+
63+
- name: Calculate new version
64+
id: version
65+
run: |
66+
IFS='.' read -r MAJOR MINOR PATCH <<< "${{ steps.current.outputs.version }}"
67+
case "${{ steps.bump.outputs.type }}" in
68+
major) MAJOR=$((MAJOR + 1)); MINOR=0; PATCH=0 ;;
69+
minor) MINOR=$((MINOR + 1)); PATCH=0 ;;
70+
patch) PATCH=$((PATCH + 1)) ;;
71+
esac
72+
NEW_VERSION="${MAJOR}.${MINOR}.${PATCH}"
73+
echo "new_version=$NEW_VERSION" >> $GITHUB_OUTPUT
74+
echo "New version: $NEW_VERSION"
75+
76+
- name: Generate changelog entry
77+
id: changelog
78+
run: |
79+
LAST_TAG=$(git describe --tags --abbrev=0 2>/dev/null || echo "")
80+
if [ -z "$LAST_TAG" ]; then RANGE="HEAD"; else RANGE="${LAST_TAG}..HEAD"; fi
81+
82+
TODAY=$(date +%Y-%m-%d)
83+
NEW_VERSION="${{ steps.version.outputs.new_version }}"
84+
ADDED="" CHANGED="" FIXED="" REMOVED=""
85+
86+
while IFS= read -r line; do
87+
HASH=$(echo "$line" | cut -d'|' -f1)
88+
MSG=$(echo "$line" | cut -d'|' -f2-)
89+
SHORT_HASH=$(echo "$HASH" | cut -c1-7)
90+
PR_NUM=$(echo "$MSG" | grep -oP '\(#\K[0-9]+(?=\))' | head -1)
91+
92+
if [ -n "$PR_NUM" ]; then
93+
ATTR="([#${PR_NUM}](https://github.com/proyecto26/animatable-component/pull/${PR_NUM}))"
94+
else
95+
ATTR="([${SHORT_HASH}](https://github.com/proyecto26/animatable-component/commit/${HASH}))"
96+
fi
97+
98+
CLEAN_MSG=$(echo "$MSG" | sed -E 's/^(feat|fix|perf|refactor|chore|docs|style|test|build|ci)(\([^)]*\))?(!)?:\s*//')
99+
CLEAN_MSG=$(echo "$CLEAN_MSG" | sed -E 's/\s*\(#[0-9]+\)\s*$//')
100+
101+
if echo "$MSG" | grep -qiE "^(feat|feature)(\(.+\))?:"; then
102+
ADDED="${ADDED}- ${CLEAN_MSG} ${ATTR}.\n"
103+
elif echo "$MSG" | grep -qiE "^fix(\(.+\))?:"; then
104+
FIXED="${FIXED}- ${CLEAN_MSG} ${ATTR}.\n"
105+
elif echo "$MSG" | grep -qiE "^(perf|refactor|chore|docs|style|build|ci)(\(.+\))?:"; then
106+
CHANGED="${CHANGED}- ${CLEAN_MSG} ${ATTR}.\n"
107+
elif echo "$MSG" | grep -qiE "^(revert)(\(.+\))?:"; then
108+
REMOVED="${REMOVED}- ${CLEAN_MSG} ${ATTR}.\n"
109+
else
110+
CHANGED="${CHANGED}- ${CLEAN_MSG} ${ATTR}.\n"
111+
fi
112+
done < <(git log $RANGE --pretty=format:"%H|%s" --no-merges 2>/dev/null)
113+
114+
if [ -n "${{ inputs.release_notes }}" ]; then
115+
ADDED="${ADDED}- ${{ inputs.release_notes }}\n"
116+
fi
117+
118+
BODY=""
119+
[ -n "$ADDED" ] && BODY="${BODY}### Added\n${ADDED}\n"
120+
[ -n "$CHANGED" ] && BODY="${BODY}### Changed\n${CHANGED}\n"
121+
[ -n "$FIXED" ] && BODY="${BODY}### Fixed\n${FIXED}\n"
122+
[ -n "$REMOVED" ] && BODY="${BODY}### Removed\n${REMOVED}\n"
123+
[ -z "$BODY" ] && BODY="### Changed\n- Release version ${NEW_VERSION}.\n"
124+
125+
echo -e "$BODY" > /tmp/release_body.md
126+
127+
# Update CHANGELOG.md
128+
PREV_VERSION="${{ steps.current.outputs.version }}"
129+
HEADER="## [${NEW_VERSION}] - ${TODAY}"
130+
LINK="[${NEW_VERSION}]: https://github.com/proyecto26/animatable-component/compare/v${PREV_VERSION}...v${NEW_VERSION}"
131+
sed -i "/^## \[Unreleased\]/a\\\\n${HEADER}\\n" CHANGELOG.md
132+
sed -i "/^## \[${NEW_VERSION}\]/r /tmp/release_body.md" CHANGELOG.md
133+
sed -i "s|\[Unreleased\]: .*|[Unreleased]: https://github.com/proyecto26/animatable-component/compare/v${NEW_VERSION}...HEAD|" CHANGELOG.md
134+
sed -i "/^\[Unreleased\]:/a ${LINK}" CHANGELOG.md
135+
136+
- name: Update version in package.json
137+
run: |
138+
node -e "
139+
const pkg = require('./package.json');
140+
pkg.version = '${{ steps.version.outputs.new_version }}';
141+
require('fs').writeFileSync('./package.json', JSON.stringify(pkg, null, 2) + '\n');
142+
"
143+
144+
- name: Commit version bump
145+
run: |
146+
git config --global user.name 'github-actions[bot]'
147+
git config --global user.email 'github-actions[bot]@users.noreply.github.com'
148+
git add -A
149+
git commit -m "chore(release): v${{ steps.version.outputs.new_version }}
150+
151+
- Updated package.json
152+
- Updated CHANGELOG.md"
153+
git tag "v${{ steps.version.outputs.new_version }}"
154+
git push origin main --follow-tags
155+
156+
- name: Create GitHub Release
157+
uses: softprops/action-gh-release@v2
158+
with:
159+
tag_name: v${{ steps.version.outputs.new_version }}
160+
name: Release ${{ steps.version.outputs.new_version }}
161+
body_path: /tmp/release_body.md
162+
draft: false
163+
prerelease: false
164+
165+
publish-npm:
166+
name: Publish to npm
167+
needs: release
168+
runs-on: ubuntu-latest
169+
if: needs.release.outputs.new_version != ''
170+
steps:
171+
- uses: actions/checkout@v4
172+
with:
173+
ref: main
174+
175+
- name: Pull latest (includes version bump commit)
176+
run: git pull origin main
177+
178+
- name: Setup Node.js
179+
uses: actions/setup-node@v4
180+
with:
181+
node-version: '20'
182+
registry-url: 'https://registry.npmjs.org'
183+
184+
- name: Install dependencies
185+
run: npm install
186+
187+
- name: Build Stencil component
188+
run: npm run build
189+
190+
- name: Publish to npm
191+
run: npm publish --access public
192+
env:
193+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

CONTRIBUTING.md

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
# Contributing
2+
3+
When contributing to this repository, please first discuss the change you wish to make via issue,
4+
email, or any other method with the owners of this repository before making a change.
5+
6+
Please note we have a code of conduct, please follow it in all your interactions with the project.
7+
8+
## Pull Request Process
9+
10+
1. Ensure any install or build dependencies are removed before the end of the layer when doing a
11+
build.
12+
2. Update the README.md with details of changes to the interface, this includes new environment
13+
variables, exposed ports, useful file locations and container parameters.
14+
3. Increase the version numbers in any examples files and the README.md to the new version that this
15+
Pull Request would represent. The versioning scheme we use is [SemVer](http://semver.org/).
16+
4. You may merge the Pull Request in once you have the sign-off of two other developers, or if you
17+
do not have permission to do that, you may request the second reviewer to merge it for you.
18+
19+
## Code of Conduct
20+
21+
### Our Pledge
22+
23+
In the interest of fostering an open and welcoming environment, we as
24+
contributors and maintainers pledge to making participation in our project and
25+
our community a harassment-free experience for everyone, regardless of age, body
26+
size, disability, ethnicity, gender identity and expression, level of experience,
27+
nationality, personal appearance, race, religion, or sexual identity and
28+
orientation.
29+
30+
### Our Standards
31+
32+
Examples of behavior that contributes to creating a positive environment
33+
include:
34+
35+
* Using welcoming and inclusive language
36+
* Being respectful of differing viewpoints and experiences
37+
* Gracefully accepting constructive criticism
38+
* Focusing on what is best for the community
39+
* Showing empathy towards other community members
40+
41+
Examples of unacceptable behavior by participants include:
42+
43+
* The use of sexualized language or imagery and unwelcome sexual attention or
44+
advances
45+
* Trolling, insulting/derogatory comments, and personal or political attacks
46+
* Public or private harassment
47+
* Publishing others' private information, such as a physical or electronic
48+
address, without explicit permission
49+
* Other conduct which could reasonably be considered inappropriate in a
50+
professional setting
51+
52+
### Our Responsibilities
53+
54+
Project maintainers are responsible for clarifying the standards of acceptable
55+
behavior and are expected to take appropriate and fair corrective action in
56+
response to any instances of unacceptable behavior.
57+
58+
Project maintainers have the right and responsibility to remove, edit, or
59+
reject comments, commits, code, wiki edits, issues, and other contributions
60+
that are not aligned to this Code of Conduct, or to ban temporarily or
61+
permanently any contributor for other behaviors that they deem inappropriate,
62+
threatening, offensive, or harmful.
63+
64+
### Scope
65+
66+
This Code of Conduct applies both within project spaces and in public spaces
67+
when an individual is representing the project or its community. Examples of
68+
representing a project or community include using an official project e-mail
69+
address, posting via an official social media account, or acting as an appointed
70+
representative at an online or offline event. Representation of a project may be
71+
further defined and clarified by project maintainers.
72+
73+
### Enforcement
74+
75+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
76+
reported by contacting the project team at jdnichollsc@hotmail.com. All
77+
complaints will be reviewed and investigated and will result in a response that
78+
is deemed necessary and appropriate to the circumstances. The project team is
79+
obligated to maintain confidentiality with regard to the reporter of an incident.
80+
Further details of specific enforcement policies may be posted separately.
81+
82+
Project maintainers who do not follow or enforce the Code of Conduct in good
83+
faith may face temporary or permanent repercussions as determined by other
84+
members of the project's leadership.
85+
86+
### Attribution
87+
88+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
89+
available at [http://contributor-covenant.org/version/1/4][version]
90+
91+
[homepage]: http://contributor-covenant.org
92+
[version]: http://contributor-covenant.org/version/1/4/

readme.md

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -40,18 +40,20 @@ Do you want to see this web component in action? Visit https://codepen.io/jdnich
4040
- Background Position: https://codepen.io/jdnichollsc/full/wvMJyYQ
4141
- Carousel: https://codepen.io/jdnichollsc/full/zYrpEyR
4242
- Confetti: https://codepen.io/jdnichollsc/full/RwWVoJN
43-
- 3D Clock: https://codepen.io/jdnichollsc/full/WNvXaYM
4443
- Cube Component: https://codepen.io/jdnichollsc/full/mdervLB
4544
- Multiple Cubes: https://codepen.io/jdnichollsc/full/XWmaYgM
45+
- 3D Clock: https://codepen.io/jdnichollsc/full/WNvXaYM
46+
- Cube Runner: https://codepen.io/jdnichollsc/full/PwzWxjv
4647
- The illusion of life:
4748
* Squash and Stretch: https://codepen.io/jdnichollsc/full/Rwrxjya
4849
* Anticipation: https://codepen.io/jdnichollsc/full/dyGJJYX
4950
* Appeal: https://codepen.io/jdnichollsc/full/GRprmVv
5051
- Solar System: https://codepen.io/jdnichollsc/full/yLYogYz
52+
- Animating other Web Components: https://codepen.io/jdnichollsc/full/mddpzbV
5153
- WorkShop: https://slides.com/juandavidnicholls/waapi-webcomponents
5254
- Meet `<animatable />`, a tiny Web Component: https://dev.to/jdnichollsc/meet-animatable-a-tiny-web-component-to-use-web-animations-api-as-a-component-1glh
5355

54-
![Animatable](https://github.com/proyecto26/animatable-component/blob/master/img/demo-pwa.png?raw=true)
56+
![Animatable](https://github.com/proyecto26/animatable-component/blob/develop/img/demo-pwa.png?raw=true)
5557
> Includes a PWA demo for debugging animations! ▶
5658
5759
## Usage 🎉
@@ -109,12 +111,12 @@ const easingOutCubic = EASING_FUNCTIONS[EASING.EASE_OUT_CUBIC];
109111

110112
### Script tag
111113

112-
- Put a script tag similar to this `<script src='https://unpkg.com/animatable-component@1.1.10/dist/animatable-component.js'></script>` in the head of your index.html
114+
- Put a script tag similar to this `<script src='https://cdn.jsdelivr.net/npm/@proyecto26/animatable-component@1.1.10/dist/animatable-component/animatable-component.esm.js'></script>` in the head of your index.html
113115
- Then you can use the element anywhere in your template, JSX, html etc
114116

115117
### Node Modules
116118
- Run `npm install @proyecto26/animatable-component --save`
117-
- Put a script tag similar to this `<script src='node_modules/@proyecto26/animatable-component/dist/animatable-component.js'></script>` in the head of your index.html
119+
- Put a script tag similar to this `<script src='node_modules/@proyecto26/animatable-component/dist/animatable-component/animatable-component.esm.js'></script>` in the head of your index.html
118120
- Then you can use the element anywhere in your template, JSX, html etc
119121

120122
### In a stencil-starter app
@@ -299,16 +301,26 @@ export class MyComponent {
299301
}
300302
```
301303

302-
303304
## Credits 👍
304305
* [Animate.css](https://daneden.github.io/animate.css)
305306
* [Animista](https://animista.net)
306307

308+
## Contributing ✨
309+
When contributing to this repository, please first discuss the change you wish to make via issue, email, or any other method with the owners of this repository before making a change.
310+
Contributions are what make the open-source community such an amazing place to learn, inspire, and create. Any contributions you make are **greatly appreciated** ❤️.
311+
You can learn more about how you can contribute to this project in the [contribution guide](https://github.com/proyecto26/animatable-component/blob/develop/CONTRIBUTING.md).
312+
307313
## Supporting 🍻
308314
I believe in Unicorns 🦄
309315
Support [me](http://www.paypal.me/jdnichollsc/2), if you do too.
310316

311-
## Enterprise 💼
317+
Donate **Ethereum**, **ADA**, **BNB**, **SHIBA**, **USDT/USDC**, **DOGE**, etc:
318+
319+
> Wallet address: jdnichollsc.eth
320+
321+
Please let us know your contributions! 🙏
322+
323+
## Enterprise Support 💼
312324

313325
Available as part of the Tidelift Subscription.
314326

@@ -317,6 +329,9 @@ The maintainers of `<animatable/>` and thousands of other packages are working w
317329
## Security contact information 🚨
318330
To report a security vulnerability, please use the [Tidelift security contact](https://tidelift.com/security). Tidelift will coordinate the fix and disclosure.
319331

332+
## License ⚖️
333+
This repository is available under the [MIT License](https://github.com/proyecto26/animatable-component/blob/develop/LICENSE).
334+
320335
## Happy coding 💯
321336
Made with ❤️
322337

0 commit comments

Comments
 (0)