Update npm-gulp.yml #6
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
name: NodeJS with Gulp | |
on: | |
push: | |
branches: [ "main" ] | |
pull_request: | |
branches: [ "main" ] | |
permissions: | |
contents: write | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- uses: actions/checkout@v4 | |
with: | |
node-version: '20' | |
- name: Use Node.js ${{ matrix.node-version }} | |
uses: actions/setup-node@v4 | |
with: | |
node-version: ${{ matrix.node-version }} | |
- name: Install dependencies and build | |
run: | | |
npm install | |
gulp | |
- name: Get latest tag and increment | |
id: version | |
run: | | |
LATEST_TAG=$(git tag --sort=-v:refname | head -n 1 || echo "1.0.0") | |
IFS='.' read -r -a parts <<< "$LATEST_TAG" | |
NEW_VERSION="${parts[0]}.${parts[1]}.$((parts[2]+1))" | |
if git rev-parse "refs/tags/$NEW_VERSION" >/dev/null 2>&1; then | |
echo "Error: Tag $NEW_VERSION already exists. Exiting." | |
exit 1 | |
fi | |
echo "NEW_VERSION=$NEW_VERSION" >> $GITHUB_ENV | |
- name: Create ZIP of public folder | |
run: | | |
zip -r public.zip public | |
- name: Push new tag | |
run: | | |
git config --global user.name "github-actions" | |
git config --global user.email "[email protected]" | |
git tag $NEW_VERSION | |
git push origin $NEW_VERSION | |
- name: Create GitHub Release | |
uses: softprops/action-gh-release@v2 | |
with: | |
tag_name: ${{ env.NEW_VERSION }} | |
name: "v${{ env.NEW_VERSION }} Website Release" | |
body: "Automated release for version v${{ env.NEW_VERSION }}" | |
files: public.zip | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |