-
Notifications
You must be signed in to change notification settings - Fork 44
144 lines (127 loc) · 4.66 KB
/
Copy pathnode-release.yaml
File metadata and controls
144 lines (127 loc) · 4.66 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
name: "[impit-node] Release to npm"
env:
DEBUG: napi:*
APP_NAME: impit-node
MACOSX_DEPLOYMENT_TARGET: '10.13'
RUSTFLAGS: '--cfg reqwest_unstable'
permissions:
contents: write
id-token: write
on:
workflow_dispatch:
inputs:
bump:
description: 'Bump version'
required: true
type: choice
default: 'patch'
options:
- 'major'
- 'minor'
- 'patch'
jobs:
test:
name: Build and test
uses: ./.github/workflows/node-test.yaml
secrets: inherit
publish:
outputs:
bumped-version-commit-sha: ${{ steps.commit.outputs.commit_long_sha }}
new_version: ${{ steps.get-new-version.outputs.TARGET_VERSION }}
defaults:
run:
working-directory: impit-node
name: Publish
runs-on: ubuntu-latest
needs: [test]
steps:
- uses: actions/checkout@v7
with:
token: ${{ secrets.APIFY_SERVICE_ACCOUNT_GITHUB_TOKEN }}
- name: Setup node
uses: actions/setup-node@v7
with:
node-version: 24
registry-url: 'https://registry.npmjs.org'
- name: Install pnpm and dependencies
uses: apify/actions/pnpm-install@v1.4.0
with:
working-directory: impit-node
- name: Download all artifacts
uses: actions/download-artifact@v8
with:
path: artifacts
- name: Move artifacts
run: pnpm artifacts
- name: List packages
run: ls -R ./npm
shell: bash
- name: Calculate version
id: get-new-version
run: |
echo "TARGET_VERSION=$(pnpm dlx semver --increment ${{ github.event.inputs.bump }} $(npm show impit version))" >> "$GITHUB_OUTPUT"
- name: Set version
run: |
pnpm version --no-git-tag-version ${{ steps.get-new-version.outputs.TARGET_VERSION }}
pnpm copy-version
- name: Publish to npm
run: pnpm publish --no-git-checks --provenance
- name: Update lockfile
run: |
for i in $(seq 1 5); do
pnpm install --lockfile-only && pnpm install --frozen-lockfile && exit 0
[ $i -lt 5 ] && echo "Attempt $i failed (lockfile out of sync, likely registry propagation lag), waiting 30s before retry..." && sleep 30
done
exit 1
- name: Commit changes
id: commit
uses: apify/actions/signed-commit@v1.4.0
with:
message: "chore(js-release): Update package version [skip ci]"
pull: '--rebase --autostash'
github-token: ${{ secrets.APIFY_SERVICE_ACCOUNT_GITHUB_TOKEN }}
- name: Create version tag
working-directory: .
env:
GH_TOKEN: ${{ secrets.APIFY_SERVICE_ACCOUNT_GITHUB_TOKEN }}
TAG_NAME: "js-${{ steps.get-new-version.outputs.TARGET_VERSION }}"
COMMIT_SHA: ${{ steps.commit.outputs.commit_long_sha }}
run: |
gh api -X POST "repos/${GITHUB_REPOSITORY}/git/refs" \
-f ref="refs/tags/${TAG_NAME}" \
-f sha="${COMMIT_SHA}"
changelog:
name: Generate changelog
needs: [publish]
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v7
with:
token: ${{ secrets.APIFY_SERVICE_ACCOUNT_GITHUB_TOKEN }}
fetch-depth: 0
ref: master
- name: Generate a changelog
uses: orhun/git-cliff-action@v4
id: git-cliff
with:
config: cliff.toml
args: --ignore-tags="(py|cli)-*" --include-path="./impit-node/**" --include-path="./impit/**"
env:
OUTPUT: impit-node/CHANGELOG.md
GITHUB_REPO: ${{ github.repository }}
- name: Commit new changelog
id: commit_changelog
uses: apify/actions/signed-commit@v1.4.0
with:
message: "docs: update changelog [skip ci]"
add: impit-node/CHANGELOG.md
pull: '--rebase --autostash'
github-token: ${{ secrets.APIFY_SERVICE_ACCOUNT_GITHUB_TOKEN }}
- name: Create release
uses: softprops/action-gh-release@v3
with:
tag_name: "js-${{ needs.publish.outputs.new_version }}"
name: "impit-node@${{ needs.publish.outputs.new_version }}"
target_commitish: ${{ needs.publish.outputs.bumped-version-commit-sha }}
body: ${{ steps.git-cliff.outputs.content }}