Skip to content

Commit f4708df

Browse files
committed
Set up GitHub Actions
1 parent 640b700 commit f4708df

File tree

1 file changed

+58
-0
lines changed

1 file changed

+58
-0
lines changed

.github/workflows/main.yaml

+58
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
name: main
2+
on: [push, pull_request]
3+
4+
jobs:
5+
build:
6+
runs-on: ubuntu-latest
7+
steps:
8+
- uses: actions/checkout@v4
9+
- run: npm ci
10+
- run: npm run build
11+
12+
publish:
13+
if: github.event_name == 'push'
14+
needs: [build]
15+
runs-on: ubuntu-latest
16+
permissions:
17+
id-token: write
18+
contents: write
19+
steps:
20+
- uses: actions/checkout@v4
21+
- id: extract-changelog
22+
uses: dahlia/submark@5a5ff0a58382fb812616a5801402f5aef00f90ce
23+
with:
24+
input-file: CHANGES.md
25+
heading-level: 3
26+
heading-title-text: version ${{ github.ref_name }}
27+
ignore-case: true
28+
omit-heading: true
29+
- run: 'cat "$CHANGES_FILE"'
30+
env:
31+
CHANGES_FILE: ${{ steps.extract-changelog.outputs.output-file }}
32+
- if: github.ref_type == 'branch'
33+
run: |
34+
jq \
35+
--arg build "$GITHUB_RUN_NUMBER" \
36+
--arg commit "${GITHUB_SHA::8}" \
37+
'.version = .version + "-dev." + $build + "+" + $commit' \
38+
package.json > package.json.tmp
39+
mv package.json.tmp package.json
40+
- run: npm ci
41+
- run: npm pack
42+
- run: |
43+
set -ex
44+
npm config set //registry.npmjs.org/:_authToken "$NPM_AUTH_TOKEN"
45+
if [[ "$GITHUB_REF_TYPE" = "tag" ]]; then
46+
npm publish --provenance --access public *.tgz
47+
else
48+
npm publish --provenance --access public --tag dev *.tgz
49+
fi
50+
env:
51+
NPM_AUTH_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }}
52+
- if: github.event_name == 'push' && github.ref_type == 'tag'
53+
uses: softprops/action-gh-release@v1
54+
with:
55+
body_path: ${{ steps.extract-changelog.outputs.output-file }}
56+
name: "@fedify/h3 ${{ github.ref_name }}"
57+
files: "*.tgz"
58+
generate_release_notes: false

0 commit comments

Comments
 (0)