Skip to content

Commit

Permalink
👷 Add tag workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
Dawidpol committed Dec 4, 2023
1 parent ddf6bd1 commit f880e07
Show file tree
Hide file tree
Showing 4 changed files with 59 additions and 4 deletions.
9 changes: 6 additions & 3 deletions .github/workflows/node.js.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ jobs:

strategy:
matrix:
os: [windows-latest, ubuntu-latest]
node-version: [14.x, 16.x, 18.x]
os: [ubuntu-latest]
node-version: [20.x]
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/

steps:
Expand All @@ -43,4 +43,7 @@ jobs:
npm test
- name: Run tests on Ubuntu
if: contains(matrix.os, 'ubuntu')
run: npm test
run: npm test
- name: Tag
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/master' }}
run: ./tag.sh
26 changes: 26 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: Publish

on:
push:
tags:
- '*'

jobs:
build:
runs-on: ubuntu-22.04
timeout-minutes: 10
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: '20.x'
registry-url: 'https://npm.pkg.github.com'
- name: Install
# Skip post-install to avoid malicious scripts stealing PAT
run: npm install --ignore-script
- name: Post-install
run: npm rebuild && npm run prepare --if-present
- name: Publish
run: npm publish
env:
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@reedsy/gm",
"description": "GraphicsMagick and ImageMagick for node.js",
"version": "1.25.0",
"version": "1.25.0-reedsy-1.0.0",
"author": "Aaron Heckmann <aaron.heckmann+github@gmail.com>",
"keywords": [
"graphics",
Expand Down
26 changes: 26 additions & 0 deletions tag.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#!/bin/bash

VERSION=$(node -p "require('./package.json').version")

git config --local user.email "github@reedsy.com"
git config --local user.name "GitHub Action"
git fetch --tags

VERSION_COUNT=$(git tag --list $VERSION | wc -l)

if [ $VERSION_COUNT -gt 0 ]
then
echo "Version $VERSION already deployed."
exit 0
else
echo "Deploying version $VERSION"
fi

echo '!/lib' >> .gitignore

git checkout -b release-$VERSION
git add .gitignore
git add --all lib/
git commit --message "Release version $VERSION"
git tag $VERSION
git push origin refs/tags/$VERSION

0 comments on commit f880e07

Please sign in to comment.