1
1
name : Release
2
2
3
3
on :
4
- push :
5
- tags :
6
- - ' v*' # Push events to matching v*, i.e. v1.0, v2.1.3
4
+ workflow_dispatch :
5
+ inputs :
6
+ major :
7
+ description : ' Major version'
8
+ required : true
9
+ default : 0
10
+ minor :
11
+ description : ' Minor version'
12
+ required : true
13
+ default : 0
14
+ patch :
15
+ description : ' Patch version'
16
+ required : true
17
+ default : 0
18
+ prerelease :
19
+ description : ' Prerelease version'
20
+ type : choice
21
+ required : false
22
+ options :
23
+ - alpha
24
+ - beta
25
+ - rc
26
+ - preview
27
+ - ' '
28
+ default : ' '
29
+ prerelease_id :
30
+ description : ' Prerelease identifier'
31
+ required : false
32
+ default : ' '
33
+
7
34
8
35
jobs :
9
- build :
36
+ release :
10
37
runs-on : ubuntu-latest
11
38
steps :
12
39
- uses : actions/checkout@v4
13
- - uses : actions/setup-node@v4
14
- with :
15
- node-version : 18
16
- - name : Install dependencies
40
+ - run : |
41
+ git config user.name "${{ github.actor }}"
42
+ git config user.email "${{ github.actor }}@users.noreply.github.com"
43
+ - name : Compute Version
44
+ id : version
17
45
run : |
18
- npm ci
19
- - uses : actions/setup-python@v5
20
- with :
21
- python-version : ' 3.10'
22
- - run : pip install ipython plotly pandas
23
- - name : Test
46
+ VERSION="${{ github.event.inputs.major }}.${{ github.event.inputs.minor }}.${{ github.event.inputs.patch }}"
47
+ if [ "${{ github.event.inputs.prerelease }}" != "" -a "${{ github.event.inputs.prerelease_id }}" != "''" ]; then
48
+ VERSION="${VERSION}-${{ github.event.inputs.prerelease }}.${{ github.event.inputs.prerelease_id }}"
49
+ elif [ "${{ github.event.inputs.prerelease }}" != "" ]; then
50
+ VERSION="${VERSION}-${{ github.event.inputs.prerelease }}.1"
51
+ fi
52
+ echo "Computed version: $VERSION"
53
+ echo "version=$VERSION" >> $GITHUB_OUTPUT
54
+ - name : Create and push tag
55
+ id : tag
24
56
run : |
25
- npm t
57
+ TAG=${{ steps.version.outputs.version }}
58
+ echo "Creating tag $TAG"
59
+ # Create tag locally if it doesn't exist.
60
+ if git rev-parse "$TAG" >/dev/null 2>&1; then
61
+ echo "Tag $TAG already exists locally."
62
+ else
63
+ git tag "$TAG"
64
+ fi
65
+ # Push tag to remote if not already pushed.
66
+ if git ls-remote --tags origin | grep -q "refs/tags/$TAG$"; then
67
+ echo "Tag $TAG already exists on remote."
68
+ else
69
+ git push origin "$TAG"
70
+ fi
71
+ echo "tag=$TAG" >> $GITHUB_OUTPUT
72
+ - name : Create GitHub Release via gh CLI
73
+ run : |
74
+ TAG=${{ steps.tag.outputs.tag }}
75
+ echo "Creating release for tag: $TAG"
76
+ gh release create "$TAG" --title "$TAG" --notes "Release $TAG"
77
+ env :
78
+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
79
+
26
80
publish :
27
- needs : build
28
81
runs-on : ubuntu-latest
82
+ needs : release
29
83
steps :
30
84
- uses : actions/checkout@v4
31
85
- uses : actions/setup-node@v4
40
94
env :
41
95
NPM_AUTH_TOKEN : ${{ secrets.NPMJS_TOKEN }}
42
96
run : |
43
- ./tasks/publish.sh
44
- # create the GitHub release
45
- - name : Create release
46
- if : startsWith(github.ref, 'refs/tags/v')
47
- uses : softprops/action-gh-release@v2
48
- env :
49
- GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
50
- with :
51
- tag_name : ${{ github.ref }}
52
- name : " ${{ github.ref }}"
53
- draft : false
54
- prerelease : false
97
+ ./tasks/publish.sh
0 commit comments