Skip to content

Commit 417659d

Browse files
authored
Fix package publishing (#4)
1 parent 7371b6b commit 417659d

File tree

5 files changed

+85
-43
lines changed

5 files changed

+85
-43
lines changed
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
name: Release and publish
2+
3+
on:
4+
push:
5+
branches: [main]
6+
7+
jobs:
8+
release-and-publish:
9+
runs-on: ubuntu-latest
10+
permissions:
11+
contents: write
12+
packages: write
13+
steps:
14+
- name: Checkout
15+
uses: actions/checkout@v4
16+
with:
17+
sparse-checkout: .
18+
fetch-depth: 0
19+
- name: Setup Node
20+
uses: actions/setup-node@v4
21+
with:
22+
node-version: 20
23+
cache: npm
24+
registry-url: 'https://registry.npmjs.org'
25+
- name: Get last release
26+
run: |
27+
COMMIT_NAME=$(git log -n 1 --pretty=format:%s)
28+
29+
LAST_RELEASE_VERSION=$(curl -L https://api.github.com/repos/$GITHUB_REPOSITORY/releases | jq -r '.|=sort_by(.name|ltrimstr("v")|split(".")|map(tonumber)|[.[0],.[1],-.[2]])|.[-1].name' | sed 's|v||')
30+
echo "Last release version: ${LAST_RELEASE_VERSION}"
31+
32+
MAIN_COMMIT=$(git rev-parse origin/main)
33+
echo "Main commit: ${MAIN_COMMIT}"
34+
LAST_RELEASE_BRANCH="release-${LAST_RELEASE_VERSION}"
35+
LAST_RELEASE_COMMIT=$(git rev-parse "origin/$LAST_RELEASE_BRANCH")
36+
echo "Last release commit: ${LAST_RELEASE_COMMIT}"
37+
38+
echo "COMMIT_NAME=$COMMIT_NAME" >> "$GITHUB_ENV"
39+
echo "LAST_RELEASE_VERSION=$LAST_RELEASE_VERSION" >> "$GITHUB_ENV"
40+
- name: Make new release version number
41+
run: |
42+
npm version "$LAST_RELEASE_VERSION" --no-git-tag-version --allow-same-version
43+
44+
TAG_NEW_VERSION=$(npm version minor --no-git-tag-version --allow-same-version)
45+
NEW_VERSION=$(echo $TAG_NEW_VERSION | sed 's|v||')
46+
47+
echo "NEW_VERSION=$NEW_VERSION" >> "$GITHUB_ENV"
48+
echo "TAG_NEW_VERSION=$TAG_NEW_VERSION" >> "$GITHUB_ENV"
49+
- name: Create new release branch
50+
run: |
51+
NEW_BRANCH="release-$NEW_VERSION"
52+
53+
git checkout -b "$NEW_BRANCH"
54+
echo "Created new release branch: $NEW_BRANCH"
55+
56+
echo "NEW_BRANCH=$NEW_BRANCH" >> "$GITHUB_ENV"
57+
- name: Commit package version
58+
run: |
59+
git config user.email "" && git config user.name "GitHub Release"
60+
git add package.json && git add package-lock.json && git commit -am "Bump version to $NEW_VERSION [release]"
61+
git push --set-upstream origin "$NEW_BRANCH"
62+
- uses: actions/create-release@v1
63+
env:
64+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
65+
with:
66+
tag_name: ${{ env.TAG_NEW_VERSION }}
67+
release_name: ${{ env.TAG_NEW_VERSION }}
68+
commitish: ${{ env.NEW_BRANCH }}
69+
body: ${{ env.COMMIT_NAME }}
70+
draft: false
71+
prerelease: false
72+
- name: Install Packages
73+
run: npm ci
74+
- name: Build
75+
run: npm run build
76+
- name: Publish
77+
run: npm publish --access=public
78+
env:
79+
NODE_AUTH_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }}

.github/workflows/release.yml

Lines changed: 0 additions & 35 deletions
This file was deleted.

.github/workflows/verify.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
name: Verify
22

33
on:
4-
push:
5-
branches: [main]
64
pull_request:
75

86
jobs:

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: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
11
{
22
"name": "@datalens-tech/ui-sandbox-modules",
3-
"version": "0.0.2",
3+
"version": "0.0.1",
44
"description": "UI-sandbox modules",
55
"repository": "https://github.com/datalens-tech/ui-sandbox-modules.git",
66
"author": "DataLens Team <https://github.com/datalens-tech>",
7+
"files": [
8+
"dist/"
9+
],
710
"scripts": {
811
"build": "rm -rf dist && NODE_OPTIONS=--max_old_space_size=4096 webpack -c webpack.config.js",
912
"prepublishOnly": "npm run build && npm pkg delete engines"
@@ -18,8 +21,5 @@
1821
"npm": ">= 9",
1922
"yarn": "Please use npm instead of yarn to install dependencies",
2023
"pnpm": "Please use npm instead of pnpm to install dependencies"
21-
},
22-
"publishConfig": {
23-
"registry": "https://npm.pkg.github.com"
2424
}
2525
}

0 commit comments

Comments
 (0)