diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index f8d9dc6..d958e2a 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -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 diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 902f4af..6b324c5 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -1,9 +1,8 @@ name: Test on: push: - branches: [develop] + branches: [master, develop] pull_request: - branches: [master, develop, next] jobs: test: name: Test