Skip to content

Merge branch 'develop' of github.com:thinger-io/node-red-contrib-thin… #59

Merge branch 'develop' of github.com:thinger-io/node-red-contrib-thin…

Merge branch 'develop' of github.com:thinger-io/node-red-contrib-thin… #59

Workflow file for this run

name: "publish"
on:
push:
branches: [ master, develop ]
jobs:
publish:
name: publish
runs-on: ubuntu-latest
steps:
- name: Extract branch name
shell: bash
run: echo "branch=${GITHUB_REF#refs/heads/}" >> $GITHUB_ENV
- name: checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
ref: ${{ env.branch }}
- name: node
uses: actions/setup-node@v3
with:
node-version: 16
registry-url: https://registry.npmjs.org
- name: Get tag version
run: |
echo "tag_version=`awk '/^## \[[0-9]+/' CHANGELOG.md | awk 'NR==1 && -F"\[\]" {print $2}' 2>/dev/null | tail -c +2 | head -c -2`" >> $GITHUB_ENV
- name: Check if tag is for develop and if it already exists
run: |
git fetch --prune --tags
if [ ${{ env.branch }} == 'develop' ]; then
for i in {1..100}; do
if [ `git tag --list | grep ${{ env.tag_version }}"-alpha.${i}" | wc -l` -eq 0 ]; then
tag_version=${{ env.tag_version }}"-alpha.${i}"
echo "tag_version=${tag_version}" >> $GITHUB_ENV
echo "npm_tag_version=develop" >> $GITHUB_ENV
break;
fi
done
elif [ ${{ env.branch }} == 'master' ]; then
echo "npm_tag_version=latest" >> $GITHUB_ENV
elif [ `git tag --list | grep -q ${{ env.tag_version }}` -ne 0 ]; then exit 1; fi
- name: Update package.json version, package-lock.json and commit
run: |
jq '.version = "'"$tag_version"'"' package.json > package.tmp && mv package.tmp package.json
npm install --package-lock-only
git config user.name "GitHub Actions Bot"
git config user.email "<>"
if [ "$(git diff --exit-code)" ]; then
git add package.json package-lock.json
git commit -m "Updated package and package-lock with ${npm_version}"
git push
fi
- name: publish
run: npm publish --tag ${{ env.npm_tag_version }} --access public
env:
NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}
- name: Get changelog body
id: get_changelog
run: |
awk '/^## \[[0-9]+/,EOF' CHANGELOG.md | awk '(NR>1)' | awk '1;/^## \[[0-9]+/{exit}' | sed '$d' > release_body.md
- name: Set pre-release boolean
run: |
prerelease=false
if [ ${{ env.branch }} == 'develop' ]; then
prerelease=true
fi
echo "prerelease=$prerelease" >> $GITHUB_ENV
- name: Create GitHub release
uses: ncipollo/release-action@v1
with:
prerelease: ${{ env.prerelease }}
tag: ${{ env.tag_version }}
name: ${{ env.tag_version }}
token: ${{ secrets.GITHUB_TOKEN }}
bodyFile: "release_body.md"