Skip to content

ci: add expected permission to publish package (#6) #2

ci: add expected permission to publish package (#6)

ci: add expected permission to publish package (#6) #2

name: publish-latest
on:
push:
branches:
- master
env:
BRANCH_NAME: ${{ github.ref_name }}
jobs:
run-lint:
name: Lint
runs-on: ubuntu-latest
steps:
- name: Check out Git repository
uses: actions/checkout@v4
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: "22.x"
registry-url: "https://registry.npmjs.org"
cache: "yarn"
- name: Install dependencies
run: yarn --prefer-offline
- name: Run linters
run: yarn lint
build:
name: Build && Publish
runs-on: ubuntu-latest
permissions:
# https://docs.github.com/en/actions/security-for-github-actions/security-hardening-your-deployments/configuring-openid-connect-in-amazon-web-services#adding-permissions-settings
id-token: write
needs: run-lint
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: "22.x"
registry-url: "https://registry.npmjs.org"
cache: "yarn"
- name: Set app version
run: echo "APP_VERSION=$(npm pkg get version | sed 's/"//g')" >> $GITHUB_ENV
- name: Set Commit
run: echo "COMMIT=$(echo ${GITHUB_SHA} | cut -c1-4)" >> $GITHUB_ENV
- name: Test Version total
run: echo ${{ env.APP_VERSION }}-${{ env.BRANCH_NAME }}-${{ env.COMMIT }}
- name: Run install
run: yarn install
- name: Git User
run: git config --global user.name "Bot"
- name: Git email
run: git config --global user.email "proxmox-sdk-bot@fake.com"
- name: Run Build
run: yarn run build
- name: Set Version
run: npm version ${{ env.APP_VERSION }}-${{ env.BRANCH_NAME }}-${{ env.COMMIT }}
- name: Publish package on NPM 📦
run: npm publish --provenance
env:
NODE_AUTH_TOKEN: ${{ secrets.NODE_AUTH_TOKEN }}