Skip to content

Commit

Permalink
ci: support releasing on pvtnbr
Browse files Browse the repository at this point in the history
  • Loading branch information
privatenumber committed Jun 20, 2024
1 parent 4572917 commit 9d7bab9
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 27 deletions.
76 changes: 51 additions & 25 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,35 +2,61 @@ name: Release

on:
push:
branches: [master, next]
branches: [master, develop]

permissions:
contents: write

jobs:
release:
name: Release
if: (
github.repository_owner == 'pvtnbr' && github.ref_name =='develop'
) || (
github.repository_owner == 'privatenumber' && github.ref_name =='master'
)
runs-on: ubuntu-latest
timeout-minutes: 10

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Use Node.js
uses: actions/setup-node@v4
with:
node-version-file: '.nvmrc'

- name: Setup pnpm
uses: pnpm/action-setup@v4
with:
run_install: true

- name: Build
run: pnpm build

- name: Test
run: pnpm test

- name: Release
env:
GH_TOKEN: ${{ secrets.GH_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
run: pnpm dlx semantic-release
- name: Checkout
uses: actions/checkout@v4
with:
token: ${{ secrets.GH_TOKEN }}

- name: Use Node.js
uses: actions/setup-node@v4
with:
node-version-file: .nvmrc

- name: Setup pnpm
uses: pnpm/action-setup@v3
with:
run_install: true

- name: Lint
run: pnpm lint

- name: Prerelease to GitHub
if: github.repository_owner == 'pvtnbr'
run: |
git remote add public https://github.com/$(echo $GITHUB_REPOSITORY | sed "s/^pvtnbr/privatenumber/")
git fetch public master 'refs/tags/*:refs/tags/*'
git push --force --tags origin refs/remotes/public/master:refs/heads/master
jq '
.publishConfig.registry = "https://npm.pkg.github.com"
| .name = ("@" + env.GITHUB_REPOSITORY_OWNER + "/" + .name)
| .repository = env.GITHUB_REPOSITORY
| .release.branches = [
"master",
{ name: "develop", prerelease: "rc", channel: "latest" }
]
' package.json > _package.json
mv _package.json package.json
- name: Release
env:
GH_TOKEN: ${{ secrets.GH_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
run: pnpm dlx semantic-release
3 changes: 1 addition & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
name: Test
on:
push:
branches: [develop]
branches: [master, develop]
pull_request:
branches: [master, develop, next]
jobs:
test:
name: Test
Expand Down

0 comments on commit 9d7bab9

Please sign in to comment.