-
Notifications
You must be signed in to change notification settings - Fork 1
79 lines (70 loc) · 2.53 KB
/
build.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
## The workflow will:
## - create a new version, build the package and run tests
## - publish a release to npm when you create a new GitHub release.
## - publish a prerelease to npm from:
## - main branch
## - all branches with #deploy_branch in the commit message.
##
## The workflow assumes the following:
## - package.json has a "version" property
## - package.json has a "name" with the format "@tfso/<my-package>"
## - package.json has the following scripts
## - "build" - build the package into the ./dist folder
## - "test"
## - the project is installable with "npm ci"
name: Build Package
on:
push:
branches:
- '**'
tags-ignore:
- '*.*'
jobs:
build:
name: Build and test
runs-on: ubuntu-latest
outputs:
version: ${{ steps.npm.outputs.version }}
prerelease: ${{ steps.npm.outputs.prerelease }}
is_prerelease: ${{ steps.npm.outputs.is_prerelease }}
deploy: ${{ steps.npm.outputs.deploy }}
steps:
- name: Install, build and test
uses: tfso/action-helpers/npm-build@v1
id: npm
with:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GITHUB_GLOBAL_TOKEN: ${{ secrets.TFSO_REPO_READ }}
NPM_TOKEN: ${{ secrets.NPM_TFSO_TOKEN }}
TRUNCATE_PRERELEASE: true
NODE_VERSION: 18
- name: upload artifact (from content in ./dist folder)
uses: actions/upload-artifact@v3
with:
name: artifact
path: ./dist
publish:
name: publish prerelease
if: ${{ needs.build.outputs.deploy == 'true' }}
needs: build
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- name: download artifact
uses: actions/download-artifact@v3
with:
name: artifact
- name: setup
uses: actions/setup-node@v4
with:
node-version: 18
registry-url: https://npm.pkg.github.com/
scope: '@tfso'
- name: Publish prerelease to Npm
run: |
npm version prerelease --preid=${{github.ref_name}}-${{github.run_number}} --no-git-tag-version
npm publish --verbose --tag dev --no-tag
env:
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}