diff --git a/.github/workflows/release-and-publish.yml b/.github/workflows/release-and-publish.yml new file mode 100644 index 0000000..0e0f31c --- /dev/null +++ b/.github/workflows/release-and-publish.yml @@ -0,0 +1,79 @@ +name: Release and publish + +on: + push: + branches: [main] + +jobs: + release-and-publish: + runs-on: ubuntu-latest + permissions: + contents: write + packages: write + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + sparse-checkout: . + fetch-depth: 0 + - name: Setup Node + uses: actions/setup-node@v4 + with: + node-version: 20 + cache: npm + registry-url: 'https://registry.npmjs.org' + - name: Get last release + run: | + COMMIT_NAME=$(git log -n 1 --pretty=format:%s) + + 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||') + echo "Last release version: ${LAST_RELEASE_VERSION}" + + MAIN_COMMIT=$(git rev-parse origin/main) + echo "Main commit: ${MAIN_COMMIT}" + LAST_RELEASE_BRANCH="release-${LAST_RELEASE_VERSION}" + LAST_RELEASE_COMMIT=$(git rev-parse "origin/$LAST_RELEASE_BRANCH") + echo "Last release commit: ${LAST_RELEASE_COMMIT}" + + echo "COMMIT_NAME=$COMMIT_NAME" >> "$GITHUB_ENV" + echo "LAST_RELEASE_VERSION=$LAST_RELEASE_VERSION" >> "$GITHUB_ENV" + - name: Make new release version number + run: | + npm version "$LAST_RELEASE_VERSION" --no-git-tag-version --allow-same-version + + TAG_NEW_VERSION=$(npm version minor --no-git-tag-version --allow-same-version) + NEW_VERSION=$(echo $TAG_NEW_VERSION | sed 's|v||') + + echo "NEW_VERSION=$NEW_VERSION" >> "$GITHUB_ENV" + echo "TAG_NEW_VERSION=$TAG_NEW_VERSION" >> "$GITHUB_ENV" + - name: Create new release branch + run: | + NEW_BRANCH="release-$NEW_VERSION" + + git checkout -b "$NEW_BRANCH" + echo "Created new release branch: $NEW_BRANCH" + + echo "NEW_BRANCH=$NEW_BRANCH" >> "$GITHUB_ENV" + - name: Commit package version + run: | + git config user.email "" && git config user.name "GitHub Release" + git add package.json && git add package-lock.json && git commit -am "Bump version to $NEW_VERSION [release]" + git push --set-upstream origin "$NEW_BRANCH" + - uses: actions/create-release@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + tag_name: ${{ env.TAG_NEW_VERSION }} + release_name: ${{ env.TAG_NEW_VERSION }} + commitish: ${{ env.NEW_BRANCH }} + body: ${{ env.COMMIT_NAME }} + draft: false + prerelease: false + - name: Install Packages + run: npm ci + - name: Build + run: npm run build + - name: Publish + run: npm publish --access=public + env: + NODE_AUTH_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }} diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml deleted file mode 100644 index 8477cc5..0000000 --- a/.github/workflows/release.yml +++ /dev/null @@ -1,35 +0,0 @@ -name: Release - -on: - workflow_run: - workflows: ['Verify'] - types: - - completed - -jobs: - release: - name: Release - runs-on: ubuntu-latest - permissions: - contents: read - packages: write - steps: - - name: Checkout - uses: actions/checkout@v4 - - name: Setup Node - uses: actions/setup-node@v4 - with: - node-version: 20 - registry-url: 'https://npm.pkg.github.com' - scope: '@datalens-tech' - cache: npm - - name: Install Packages - run: npm ci - - name: Build - run: npm run build - - name: Git user configuration - run: git config user.email "datalens-tech+bot@github.com" && git config user.name "Datalens-tech robot" - - name: Publish - run: npm version patch && npm publish - env: - NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/verify.yml b/.github/workflows/verify.yml index ab77fef..1e008bb 100644 --- a/.github/workflows/verify.yml +++ b/.github/workflows/verify.yml @@ -1,8 +1,6 @@ name: Verify on: - push: - branches: [main] pull_request: jobs: diff --git a/package-lock.json b/package-lock.json index 90fe4dd..6d4a660 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@datalens-tech/ui-sandbox-modules", - "version": "0.0.2", + "version": "0.0.1", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@datalens-tech/ui-sandbox-modules", - "version": "0.0.2", + "version": "0.0.1", "devDependencies": { "@gravity-ui/date-utils.2.3.0": "npm:@gravity-ui/date-utils@^2.3.0", "@gravity-ui/date-utils.2.5.3": "npm:@gravity-ui/date-utils@^2.5.3", diff --git a/package.json b/package.json index 8b30588..80c0ee7 100644 --- a/package.json +++ b/package.json @@ -1,9 +1,12 @@ { "name": "@datalens-tech/ui-sandbox-modules", - "version": "0.0.2", + "version": "0.0.1", "description": "UI-sandbox modules", "repository": "https://github.com/datalens-tech/ui-sandbox-modules.git", "author": "DataLens Team ", + "files": [ + "dist/" + ], "scripts": { "build": "rm -rf dist && NODE_OPTIONS=--max_old_space_size=4096 webpack -c webpack.config.js", "prepublishOnly": "npm run build && npm pkg delete engines" @@ -18,8 +21,5 @@ "npm": ">= 9", "yarn": "Please use npm instead of yarn to install dependencies", "pnpm": "Please use npm instead of pnpm to install dependencies" - }, - "publishConfig": { - "registry": "https://npm.pkg.github.com" } }