Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
91 changes: 91 additions & 0 deletions .github/workflows/build-release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
name: build-release

on:
push:
branches:
- main

jobs:
release:
runs-on: ubuntu-latest
permissions:
id-token: write
contents: write
outputs:
new_version: ${{ steps.version.outputs.version }}
released: ${{ steps.version.outputs.released }}
steps:
- name: Repo checkout
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Resolve version from package.json
id: version
run: |
VERSION=$(jq -r .version package.json)
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
if git rev-parse "v$VERSION" >/dev/null 2>&1; then
echo "released=false" >> "$GITHUB_OUTPUT"
echo "Tag v$VERSION already exists — skipping release."
else
echo "released=true" >> "$GITHUB_OUTPUT"
fi

- name: Create release
if: steps.version.outputs.released == 'true'
uses: ncipollo/release-action@v1
with:
tag: v${{ steps.version.outputs.version }}
generateReleaseNotes: true

publish-npmjs:
runs-on: ubuntu-latest
needs: [release]
if: needs.release.outputs.released == 'true'
permissions:
contents: read
id-token: write
steps:
- uses: actions/checkout@v4

- uses: actions/setup-node@v4
with:
node-version: '20.x'
registry-url: 'https://registry.npmjs.org'

- name: Update NPM
run: npm install -g npm@latest

- name: Install dependencies
run: npm install

- name: Publish package
run: npm publish --provenance --access public
Comment thread
aurimasbutkus marked this conversation as resolved.

publish-github:
runs-on: ubuntu-latest
needs: [release]
if: needs.release.outputs.released == 'true'
permissions:
contents: read
id-token: write
packages: write
steps:
- uses: actions/checkout@v4

- uses: actions/setup-node@v4
with:
node-version: '20.x'
registry-url: 'https://npm.pkg.github.com'
scope: '@hostinger'

- name: Install dependencies
run: npm install

- name: Publish package
run: |
sed -i 's+"name": ".*+"name": "@${{ github.repository }}",+gI' ./package.json
npm publish --provenance --access public
env:
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Comment thread
aurimasbutkus marked this conversation as resolved.