-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
107 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
name: Build and Release | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
|
||
permissions: | ||
contents: write | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v3 | ||
|
||
- name: Set up Node.js | ||
uses: actions/setup-node@v3 | ||
with: | ||
node-version: '18' | ||
|
||
- name: Install dependencies | ||
run: npm install | ||
|
||
- name: Run tests | ||
run: npm run test | ||
|
||
- name: Build the package | ||
run: npm run build | ||
|
||
- name: Bump version and generate changelog | ||
run: | | ||
git config --global user.name 'Eslam3bed' | ||
git config --global user.email '[email protected]' | ||
npm run release | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- name: Commit changelog and version bump | ||
id: commit_version | ||
run: | | ||
git config --global user.name 'github-actions[bot]' | ||
git config --global user.email 'github-actions[bot]@users.noreply.github.com' | ||
# Check if there are any changes to commit | ||
if ! git diff --quiet; then | ||
git add . | ||
git commit -m "chore(release): $(node -p -e "require('./package.json').version") [skip ci]" | ||
git tag v$(node -p -e "require('./package.json').version") | ||
echo "version_bumped=true" >> $GITHUB_ENV | ||
else | ||
echo "No changes to commit." | ||
echo "version_bumped=false" >> $GITHUB_ENV | ||
fi | ||
- name: Push changes to main branch | ||
if: env.version_bumped == 'true' | ||
run: | | ||
git checkout main | ||
git push origin main --follow-tags | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
name: Publish | ||
|
||
on: | ||
release: | ||
types: [published] | ||
|
||
permissions: | ||
contents: write | ||
|
||
jobs: | ||
release: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v3 | ||
|
||
- name: Tag the repository | ||
id: tag | ||
run: | | ||
TAG=v$(date -Iseconds | sed 's/[T:\+]/-/g') | ||
echo "$TAG" | ||
echo "tag=$TAG" >> $GITHUB_OUTPUT | ||
git config --global user.name 'github-actions[bot]' | ||
git config --global user.email 'github-actions[bot]@users.noreply.github.com' | ||
git tag -a $TAG -m "Published version $TAG" ${GITHUB_SHA} | ||
git push origin $TAG | ||
- name: Publish to npm | ||
run: npm publish | ||
env: | ||
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} | ||
|
||
- name: Create a release on GitHub | ||
uses: softprops/action-gh-release@v1 | ||
with: | ||
files: dist/* | ||
tag_name: ${{ steps.tag.outputs.tag }} | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |