Skip to content

Commit c9ab63d

Browse files
committed
refactor GitHub Actions workflows for improved release process and versioning
update release workflow #22
1 parent b497b4d commit c9ab63d

File tree

2 files changed

+72
-29
lines changed

2 files changed

+72
-29
lines changed

.github/workflows/build.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Build JavaScript
1+
name: CI AsciiDoc Extensions
22

33
on:
44
push:

.github/workflows/release.yml

Lines changed: 71 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,85 @@
11
name: Release
22

33
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+
734

835
jobs:
9-
build:
36+
release:
1037
runs-on: ubuntu-latest
1138
steps:
1239
- 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
1745
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
2456
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+
2680
publish:
27-
needs: build
2881
runs-on: ubuntu-latest
82+
needs: release
2983
steps:
3084
- uses: actions/checkout@v4
3185
- uses: actions/setup-node@v4
@@ -40,15 +94,4 @@ jobs:
4094
env:
4195
NPM_AUTH_TOKEN: ${{ secrets.NPMJS_TOKEN }}
4296
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

Comments
 (0)