-
Notifications
You must be signed in to change notification settings - Fork 0
78 lines (77 loc) · 2.73 KB
/
auto-release.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
name: Trigger Release
on:
push:
tags:
- 'v*'
jobs:
define-variables:
name: Defining and extracting Variables
runs-on: ubuntu-latest
outputs:
version: ${{ steps.get_version.outputs.VERSION }}
label: ${{ steps.get_label.outputs.LABEL }}
pre_release: ${{ steps.prerelease_check.outputs.PRE_RELEASE }}
steps:
- uses: actions/checkout@v4
- name: Get Version
id: get_version
# E.g. converts ref/tags/v0.0.1 -> 0.0.1
run: echo "VERSION=$(echo $GITHUB_REF | cut -d / -f 3 | cut -c 2-)" >> $GITHUB_OUTPUT
- name: Get Label
id: get_label
# E.g. converts 0.0.1-beta.1 -> beta
run: echo "LABEL=$(echo ${{ steps.get_version.outputs.VERSION }} | awk -F '-' '{split($2, arr, "."); print arr[1]}')" >> $GITHUB_OUTPUT
- name: Check for Pre-Release or Release
id: prerelease_check
# perform secret check & put boolean result as an output
run: |
if [ "${{ steps.get_label.outputs.LABEL }}" != '' ]; then
echo "PRE_RELEASE=true" >> $GITHUB_OUTPUT
else
echo "PRE_RELEASE=false" >> $GITHUB_OUTPUT
fi
create-release:
needs: [define-variables]
name: Create Github Release
if: needs.define-variables.outputs.pre_release == 'false'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: 'marvinpinto/action-automatic-releases@latest'
name: Publish Release
with:
repo_token: '${{ secrets.GITHUB_TOKEN }}'
prerelease: false
title: ${{ needs.define-variables.outputs.version }}
create-prerelease:
needs: [define-variables]
name: Create Github Pre-Release
if: needs.define-variables.outputs.pre_release == 'true'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: 'marvinpinto/action-automatic-releases@latest'
name: Publish Release
with:
repo_token: '${{ secrets.GITHUB_TOKEN }}'
prerelease: true
title: ${{ needs.define-variables.outputs.version }}
github:
name: Build & Publish Package
needs: [define-variables]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0 # Mandatory to use the extract version from tag action
- uses: actions/setup-node@v4
with:
node-version: 20
registry-url: https://npm.pkg.github.com/
- run: npm ci
- run: npm run lib:build
- run: node build/update-version.js --version ${{ needs.define-variables.outputs.version }}
- run: cp README.md dist/ng-infinite-scroll
- run: cd dist/ng-infinite-scroll && npm publish
env:
NODE_AUTH_TOKEN: ${{secrets.GITHUB_TOKEN}}