49 lines
		
	
	
		
			1.7 KiB
		
	
	
	
		
			YAML
		
	
	
	
	
	
			
		
		
	
	
			49 lines
		
	
	
		
			1.7 KiB
		
	
	
	
		
			YAML
		
	
	
	
	
	
name: Publish Library
 | 
						|
run-name: Publish Library
 | 
						|
 | 
						|
on:
 | 
						|
    push:
 | 
						|
 | 
						|
jobs:
 | 
						|
    build:
 | 
						|
        name: Build NPM Project
 | 
						|
        runs-on: ubuntu-latest
 | 
						|
        container: node:alpine
 | 
						|
        steps:
 | 
						|
            - name: Clone Repository
 | 
						|
              uses: ztimson/actions/clone@develop
 | 
						|
 | 
						|
            - name: Install & Build
 | 
						|
              run: npm i && npm run build
 | 
						|
 | 
						|
            - name: Publish Library
 | 
						|
              run: |
 | 
						|
                  if [ "${{github.ref_name}}" = "master" ]; then
 | 
						|
                    REGISTRY="${{github.server_url}}/api/packages/${{github.repository_owner}}/npm/"
 | 
						|
                    npm set registry "$REGISTRY"
 | 
						|
                    npm set $(echo $REGISTRY | sed s%http:%% | sed s%https:%% ):_authToken "${{secrets.DEPLOY_TOKEN}}"
 | 
						|
                    npm publish || echo "Failed to publish"
 | 
						|
 | 
						|
                    REGISTRY="https://registry.npmjs.org/"
 | 
						|
                    npm set registry "$REGISTRY"
 | 
						|
                    npm set $(echo $REGISTRY | sed s%http:%% | sed s%https:%% ):_authToken "${{secrets.NPM_TOKEN}}"
 | 
						|
                    npm publish || echo "Failed to publish"
 | 
						|
                  fi
 | 
						|
    tag:
 | 
						|
        name: Tag Version
 | 
						|
        needs: build
 | 
						|
        if: ${{github.ref_name}} == 'release'
 | 
						|
        runs-on: ubuntu-latest
 | 
						|
        container: node:alpine
 | 
						|
        steps:
 | 
						|
            -   name: Clone Repository
 | 
						|
                uses: ztimson/actions/clone@develop
 | 
						|
 | 
						|
            -   name: Get Version Number
 | 
						|
                run: echo "VERSION=$(cat package.json | grep version | grep -Eo ':.+' | grep -Eo '[[:alnum:]\.\/\-]+')" >> $GITHUB_ENV
 | 
						|
 | 
						|
            -   name: Tag Version
 | 
						|
                uses: ztimson/actions/tag@develop
 | 
						|
                with:
 | 
						|
                    tag: ${{env.VERSION}}
 |