-
-
Notifications
You must be signed in to change notification settings - Fork 2
148 lines (127 loc) · 5.37 KB
/
Copy pathrelease.yml
File metadata and controls
148 lines (127 loc) · 5.37 KB
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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
name: Create GitHub Release and publish to npm
on:
workflow_run:
workflows: ["Tests"]
types:
- completed
branches:
- main
jobs:
CheckVersion:
if: github.event.workflow_run.event == 'push' && github.event.workflow_run.head_branch == 'main' && github.event.workflow_run.conclusion == 'success'
runs-on: ubuntu-latest
outputs:
versionChanged: ${{ steps.check_version.outputs.changed }}
newVersion: ${{ steps.check_version.outputs.version }}
steps:
- name: Set up Git repository
uses: actions/checkout@v7
with:
ref: ${{ github.event.workflow_run.head_sha }}
fetch-depth: 0
fetch-tags: true
# A release is due when the package.json version has no matching git tag yet
- name: Check whether this version still needs releasing
id: check_version
run: |
VERSION=$(node -p "require('./package.json').version")
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
if git rev-parse -q --verify "refs/tags/v$VERSION" >/dev/null; then
echo "changed=false" >> "$GITHUB_OUTPUT"
echo "v$VERSION is already tagged - nothing to release."
else
echo "changed=true" >> "$GITHUB_OUTPUT"
echo "v$VERSION has no tag yet - a release will be created."
fi
CreateRelease:
needs: CheckVersion
if: needs.CheckVersion.outputs.versionChanged == 'true'
runs-on: ubuntu-latest
steps:
- name: Set up Git repository
uses: actions/checkout@v7
with:
ref: ${{ github.event.workflow_run.head_sha }}
fetch-depth: 0
fetch-tags: true
- name: Copy required files to release_files folder
run: |
mkdir release_files
cp ./LICENSE ./release_files/LICENSE
cp ./README.md ./release_files/README.md
cp -r ./bin ./release_files/bin
cp -r ./js ./release_files/js
cp ./config.default.json ./release_files/config.default.json
cp ./config.schema.json ./release_files/config.schema.json
cp ./index.js ./release_files/index.js
cp ./package-lock.json ./release_files/package-lock.json
cp ./package.json ./release_files/package.json
- name: Create .zip of required files
run: |
cd release_files
zip -r ../Notion.Steam.API.Integration.zip *
- name: Create Release notes
run: |
cat > CHANGELOG.md <<'EOF'
> **Recommended:** install from npm with `npm install -g notion-steam-api-integration` (or run it directly with `npx notion-steam-api-integration`) to always get the latest version. See the [README](https://github.com/NikkelM/Notion-Steam-API-Integration#readme) for all options.
## What's Changed
EOF
LAST_TAG=$(git describe --tags "$(git rev-list --tags --max-count=1)")
git log --pretty=format:'* %s' "$LAST_TAG"..HEAD >> CHANGELOG.md
cat >> CHANGELOG.md <<'EOF'
## Using the release asset
To run this version offline, download the attached `Notion.Steam.API.Integration.zip`, unzip it, and from inside the folder run:
```bash
npm ci # install dependencies from the bundled lockfile
node bin/cli.js init # create a config.json interactively (or add one yourself)
node bin/cli.js # start the integration
```
Requires [Node.js](https://nodejs.org) 22.13 or newer. Run `node bin/cli.js --help` for all commands.
EOF
- name: Create Release
uses: softprops/action-gh-release@v3
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: v${{ needs.CheckVersion.outputs.newVersion }}
name: v${{ needs.CheckVersion.outputs.newVersion }}
files: Notion.Steam.API.Integration.zip
body_path: CHANGELOG.md
PublishNpm:
needs: CheckVersion
if: needs.CheckVersion.outputs.versionChanged == 'true'
runs-on: ubuntu-latest
permissions:
contents: read
id-token: write # Required for npm Trusted Publishing (OIDC)
steps:
- name: Set up Git repository
uses: actions/checkout@v7
with:
ref: ${{ github.event.workflow_run.head_sha }}
- name: Set up node
uses: actions/setup-node@v6
with:
node-version: 24
registry-url: 'https://registry.npmjs.org'
# Trusted Publishing (token-free OIDC) needs a recent npm; the bundled one may be too old
- name: Update npm
run: npm install -g npm@latest
- name: Install dependencies
run: npm ci
# Publishing is idempotent: skip if this version is already on npm
- name: Skip if this version is already on npm
id: published
run: |
NAME=$(node -p "require('./package.json').name")
VERSION=$(node -p "require('./package.json').version")
if [ -n "$(npm view "$NAME@$VERSION" version 2>/dev/null || true)" ]; then
echo "exists=true" >> "$GITHUB_OUTPUT"
echo "Version $VERSION is already on npm - skipping publish."
else
echo "exists=false" >> "$GITHUB_OUTPUT"
fi
# Authentication and provenance are handled via OIDC Trusted Publishing
- name: Publish to npm
if: steps.published.outputs.exists == 'false'
run: npm publish