From 0bf1dd727e5bc0ed33199d5a164f3faadcbad5a4 Mon Sep 17 00:00:00 2001 From: Ilya Gonchar Date: Fri, 21 Nov 2025 00:52:05 +0100 Subject: [PATCH 1/2] added ci/cd automation --- .github/workflows/docs.yml | 63 +++++++++++++++++++ .github/workflows/publish.yml | 110 ++++++++++++++++++++++++++++++++++ .github/workflows/test.yml | 41 +++++++++++++ package.json | 9 ++- 4 files changed, 220 insertions(+), 3 deletions(-) create mode 100644 .github/workflows/docs.yml create mode 100644 .github/workflows/publish.yml create mode 100644 .github/workflows/test.yml diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml new file mode 100644 index 0000000..a42004b --- /dev/null +++ b/.github/workflows/docs.yml @@ -0,0 +1,63 @@ +name: Generate Documentation + +on: + push: + branches: + - master + +permissions: + contents: write + pages: write + id-token: write + +concurrency: + group: "pages" + cancel-in-progress: false + +jobs: + generate-docs: + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Setup Node.js + uses: actions/setup-node@v4 + with: + node-version: '18' + + - name: Setup Yarn + uses: actions/setup-node@v4 + with: + node-version: '18' + + - name: Enable Corepack + run: corepack enable + + - name: Install dependencies + run: yarn install --frozen-lockfile + + - name: Generate documentation + run: yarn docs + + - name: Setup Pages + uses: actions/configure-pages@v4 + + - name: Upload artifact + uses: actions/upload-pages-artifact@v3 + with: + path: './docs' + + deploy: + runs-on: ubuntu-latest + needs: generate-docs + if: github.ref == 'refs/heads/main' || github.ref == 'refs/heads/master' + permissions: + pages: write + id-token: write + + steps: + - name: Deploy to GitHub Pages + uses: actions/deploy-pages@v4 + diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml new file mode 100644 index 0000000..e8740f3 --- /dev/null +++ b/.github/workflows/publish.yml @@ -0,0 +1,110 @@ +name: Build and Publish + +on: + push: + branches: + - master + +jobs: + build-and-publish: + runs-on: ubuntu-latest + permissions: + contents: write + packages: write + + steps: + - name: Checkout code + uses: actions/checkout@v4 + with: + token: ${{ secrets.GITHUB_TOKEN }} + + - name: Setup Node.js + uses: actions/setup-node@v4 + with: + node-version: '18' + registry-url: 'https://npm.pkg.github.com' + scope: '@${{ github.repository_owner }}' + + - name: Setup Yarn + uses: actions/setup-node@v4 + with: + node-version: '18' + + - name: Enable Corepack + run: corepack enable + + - name: Install dependencies + run: yarn install --frozen-lockfile + + - name: Build project + run: yarn build + + - name: Publish to GitHub Packages + env: + NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + # Get version from package.json + VERSION=$(node -p "require('./package.json').version") + + # Remove 'v' prefix if present + VERSION=${VERSION#v} + + # Update package.json version + npm version $VERSION --no-git-tag-version + + # Configure npm authentication for GitHub Packages + echo "//npm.pkg.github.com/:_authToken=${{ secrets.GITHUB_TOKEN }}" >> .npmrc + + # Publish + npm publish + + - name: Create Release + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + # Get version from package.json (before restoring original name) + VERSION=$(node -p "require('./package.json').version") + VERSION=${VERSION#v} + TAG_NAME="v$VERSION" + + # Configure git + git config --local user.email "action@github.com" + git config --local user.name "GitHub Action" + + # Create git tag if it doesn't exist + if ! git rev-parse "$TAG_NAME" >/dev/null 2>&1; then + git tag "$TAG_NAME" + git push origin "$TAG_NAME" + fi + + # Create GitHub release using GitHub API + RELEASE_RESPONSE=$(curl -s -w "\n%{http_code}" -X POST \ + -H "Authorization: token $GITHUB_TOKEN" \ + -H "Accept: application/vnd.github.v3+json" \ + "https://api.github.com/repos/${{ github.repository }}/releases" \ + -d "{\"tag_name\":\"$TAG_NAME\",\"name\":\"$TAG_NAME\",\"body\":\"Release $TAG_NAME\",\"draft\":false,\"prerelease\":false}") + + HTTP_CODE=$(echo "$RELEASE_RESPONSE" | tail -n1) + if [ "$HTTP_CODE" = "201" ]; then + echo "Release $TAG_NAME created successfully" + elif [ "$HTTP_CODE" = "422" ]; then + echo "Release $TAG_NAME already exists" + else + echo "Failed to create release. HTTP code: $HTTP_CODE" + echo "$RELEASE_RESPONSE" + fi + + - name: Increment version + run: | + # Configure git + git config --local user.email "action@github.com" + git config --local user.name "GitHub Action" + + # Increment patch version + npm version patch --no-git-tag-version + + # Commit and push version increment + git add package.json + git commit -m "chore: increment version after release" + git push + diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..22976a1 --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,41 @@ +name: Test + +on: + pull_request: + branches: + - main + - master + +jobs: + test: + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Setup Node.js + uses: actions/setup-node@v4 + with: + node-version: '18' + + - name: Setup Yarn + uses: actions/setup-node@v4 + with: + node-version: '18' + + - name: Enable Corepack + run: corepack enable + + - name: Install dependencies + run: yarn install --frozen-lockfile + + - name: Run linter + run: yarn lint + + - name: Compile TypeScript + run: yarn compile + + - name: Run tests + run: yarn test + diff --git a/package.json b/package.json index 82e49cb..2f5bc94 100644 --- a/package.json +++ b/package.json @@ -1,5 +1,5 @@ { - "name": "sequency", + "name": "@kraken-crypto/sequency", "version": "0.20.0", "description": "Functional sequences for processing iterable data in JavaScript", "main": "./lib/cjs/sequency.js", @@ -34,10 +34,10 @@ "license": "MIT", "repository": { "type": "git", - "url": "https://github.com/winterbe/sequency.git" + "url": "https://github.com/Kraken-crypto/sequency.git" }, "bugs": { - "url": "https://github.com/winterbe/sequency/issues" + "url": "https://github.com/Kraken-crypto/sequency/issues" }, "files": [ "lib", @@ -46,6 +46,9 @@ "engines": { "node": ">=6.0.0" }, + "publishConfig": { + "registry": "https://npm.pkg.github.com" + }, "packageManager": "yarn@4.1.1", "devDependencies": { "@size-limit/preset-small-lib": "^11.1.2", From 21dd8c3d65b77a737d3869f3598e4a13dcec554a Mon Sep 17 00:00:00 2001 From: Ilya Gonchar Date: Fri, 21 Nov 2025 00:55:12 +0100 Subject: [PATCH 2/2] chore: update yarn.lock after package name change --- yarn.lock | 42 +++++++++++++++++++++--------------------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/yarn.lock b/yarn.lock index d182ac6..1ad307e 100644 --- a/yarn.lock +++ b/yarn.lock @@ -893,6 +893,27 @@ __metadata: languageName: node linkType: hard +"@kraken-crypto/sequency@workspace:.": + version: 0.0.0-use.local + resolution: "@kraken-crypto/sequency@workspace:." + dependencies: + "@size-limit/preset-small-lib": "npm:^11.1.2" + "@types/jest": "npm:^29.5.12" + gh-pages: "npm:^6.1.1" + jest: "npm:^29.7.0" + rimraf: "npm:^5.0.5" + size-limit: "npm:^11.1.2" + terser-webpack-plugin: "npm:^5.3.10" + ts-jest: "npm:^29.1.2" + ts-loader: "npm:^9.5.1" + tslint: "npm:^6.1.3" + typedoc: "npm:^0.25.12" + typescript: "npm:^5.4.3" + webpack: "npm:^5.91.0" + webpack-cli: "npm:^5.1.4" + languageName: unknown + linkType: soft + "@nodelib/fs.scandir@npm:2.1.5": version: 2.1.5 resolution: "@nodelib/fs.scandir@npm:2.1.5" @@ -4361,27 +4382,6 @@ __metadata: languageName: node linkType: hard -"sequency@workspace:.": - version: 0.0.0-use.local - resolution: "sequency@workspace:." - dependencies: - "@size-limit/preset-small-lib": "npm:^11.1.2" - "@types/jest": "npm:^29.5.12" - gh-pages: "npm:^6.1.1" - jest: "npm:^29.7.0" - rimraf: "npm:^5.0.5" - size-limit: "npm:^11.1.2" - terser-webpack-plugin: "npm:^5.3.10" - ts-jest: "npm:^29.1.2" - ts-loader: "npm:^9.5.1" - tslint: "npm:^6.1.3" - typedoc: "npm:^0.25.12" - typescript: "npm:^5.4.3" - webpack: "npm:^5.91.0" - webpack-cli: "npm:^5.1.4" - languageName: unknown - linkType: soft - "serialize-javascript@npm:^6.0.1": version: 6.0.2 resolution: "serialize-javascript@npm:6.0.2"