Skip to content

fix:fix github url processing to ensure sponsors url are correctly fo… #54

fix:fix github url processing to ensure sponsors url are correctly fo…

fix:fix github url processing to ensure sponsors url are correctly fo… #54

Workflow file for this run

name: Releases
on:
workflow_dispatch:
push:
branches: [main]
paths:
- "src/**"
pull_request:
branches:
- main
jobs:
release:
name: Build, test, and release
runs-on: ubuntu-latest
permissions:
contents: write
issues: write
pull-requests: write
packages: write
id-token: write
actions: write
steps:
- name: Checkout
uses: actions/[email protected]
with:
fetch-depth: 0
persist-credentials: false
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: "lts/*"
registry-url: "https://registry.npmjs.org"
- name: Install dependencies
run: npm install
- name: Build
run: npm run build
- name: Run tests
continue-on-error: true
run: npm run test
- name: Semantic Release
env:
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
GIT_AUTHOR_NAME: ${{ github.actor }}
GIT_AUTHOR_EMAIL: ${{ github.actor }}@users.noreply.github.com
GIT_COMMITTER_NAME: ${{ github.actor }}
GIT_COMMITTER_EMAIL: ${{ github.actor }}@users.noreply.github.com
run: npx semantic-release
# Add step to publish to GitHub Marketplace
- name: Publish to GitHub Marketplace
if: github.event_name != 'pull_request'
uses: actions/github-script@v7
with:
github-token: ${{ secrets.GH_TOKEN }}
script: |
const fs = require('fs');
const { promisify } = require('util');
const readFileAsync = promisify(fs.readFile);
try {
// Read the current release version
const pkgJson = JSON.parse(await readFileAsync('package.json', 'utf8'));
const version = pkgJson.version;
// Get the latest release
const releases = await github.rest.repos.listReleases({
owner: context.repo.owner,
repo: context.repo.repo
});
const latestRelease = releases.data[0];
if (!latestRelease) {
throw new Error('No release found');
}
// Update the release to be published to the marketplace
await github.rest.repos.updateRelease({
owner: context.repo.owner,
repo: context.repo.repo,
release_id: latestRelease.id,
draft: false,
prerelease: false,
make_latest: true
});
console.log('Successfully published to GitHub Marketplace');
} catch (error) {
console.error('Error publishing to marketplace:', error);
throw error;
}