Skip to content

Commit f13cd68

Browse files
committed
Polishing workflows
1 parent 28b826c commit f13cd68

File tree

5 files changed

+57
-27
lines changed

5 files changed

+57
-27
lines changed

.github/dependabot.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@ version: 2
22

33
updates:
44
- package-ecosystem: npm
5-
directory: "/"
5+
directory: /
66
schedule:
7-
interval: "weekly"
7+
interval: weekly
Lines changed: 51 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1-
name: Build and Release
1+
name: Build and release
22

33
on:
4+
push:
5+
branches: [master]
46
workflow_dispatch:
57
inputs:
68
tag:
@@ -9,36 +11,64 @@ on:
911

1012
jobs:
1113
release:
12-
name: Create Release
1314
runs-on: ubuntu-latest
1415
steps:
15-
- name: Checkout code
16-
uses: actions/[email protected]
16+
- uses: actions/[email protected]
1717
with:
1818
fetch-depth: 0
19-
- name: Set up Node.js
20-
uses: actions/[email protected]
19+
- uses: actions/[email protected]
2120
with:
2221
node-version: '20'
23-
- name: Install dependencies
24-
run: npm install
25-
- name: Build with ncc
26-
run: npm run build
27-
- name: Zip build artifacts
28-
run: zip -r build-${{ github.event.inputs.tag }}.zip index.js
29-
- name: Create tag
22+
- run: npm install
23+
- name: Bump version in package.json if needed
24+
if: github.event_name == 'workflow_dispatch'
3025
run: |
26+
TAG=${{ github.event.inputs.tag }}
27+
VER=${TAG#v}
28+
npm version $VER --no-git-tag-version
3129
git config user.name "github-actions[bot]"
3230
git config user.email "github-actions[bot]@users.noreply.github.com"
33-
rm -rf src
31+
git add package.json package-lock.json
32+
git commit -m "chore: bump to v${VER}"
33+
git push origin HEAD
34+
- id: get_version
35+
run: |
36+
VERSION=$(node -p "require('./package.json').version")
37+
echo "VERSION=$VERSION" >> $GITHUB_OUTPUT
38+
- name: Check if tag already exists
39+
id: tag_check
40+
run: |
41+
T=v${{ steps.get_version.outputs.VERSION }}
42+
if git rev-parse "$T" >/dev/null 2>&1; then
43+
echo "skip=true" >> $GITHUB_OUTPUT
44+
else
45+
echo "skip=false" >> $GITHUB_OUTPUT
46+
fi
47+
- if: steps.tag_check.outputs.skip == 'false'
48+
name: Build and zip
49+
run: |
50+
npm run build
51+
zip -r build-v${{ steps.get_version.outputs.VERSION }}.zip index.js
52+
- if: steps.tag_check.outputs.skip == 'false'
53+
name: Create tag with only build output
54+
run: |
55+
git config user.name "github-actions[bot]"
56+
git config user.email "github-actions[bot]@users.noreply.github.com"
57+
TAG=v${{ steps.get_version.outputs.VERSION }}
58+
TMP_BRANCH=release-tmp-$TAG
59+
git checkout -b $TMP_BRANCH
60+
git rm -rf src
3461
git add -f index.js
35-
git add -u
36-
git commit -m "Build for release ${{ github.event.inputs.tag }}"
37-
git tag ${{ github.event.inputs.tag }}
38-
git push origin ${{ github.event.inputs.tag }}
39-
- name: Create GitHub release
40-
id: create_release
62+
git reset HEAD package.json package-lock.json
63+
git commit -m "build: release $TAG"
64+
git tag $TAG
65+
git push origin $TAG
66+
git checkout master
67+
git branch -D $TMP_BRANCH
68+
- if: steps.tag_check.outputs.skip == 'false'
69+
name: Create GitHub release
4170
uses: softprops/[email protected]
4271
with:
43-
tag_name: ${{ github.event.inputs.tag }}
72+
tag_name: v${{ steps.get_version.outputs.VERSION }}
4473
generate_release_notes: true
74+
files: build-v${{ steps.get_version.outputs.VERSION }}.zip

.github/workflows/test.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,12 @@ jobs:
1212
runs-on: ubuntu-latest
1313
steps:
1414
- uses: actions/[email protected]
15+
- run: npm install
1516
- name: Check formatting with js-beautify
1617
run: |
1718
npx js-beautify -r -n "**/*.js"
1819
npx js-beautify -r -n "package.json"
1920
git diff --exit-code
20-
- run: npm install
2121
- run: npm run build
2222
- name: Run action with inclusive upper bound
2323
uses: ./

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "get-supported-ghc",
3-
"version": "0.0.3",
3+
"version": "0.0.5",
44
"main": "index.js",
55
"scripts": {
66
"build": "ncc build src/index.js -o ."

0 commit comments

Comments
 (0)