|
| 1 | +# GitHub Actions |
| 2 | + |
| 3 | +This directory contains GitHub Actions workflows for building and publishing the CCXT library. |
| 4 | + |
| 5 | +## Workflows |
| 6 | + |
| 7 | +### Build and Test (`build.yml`) |
| 8 | +- Runs on pull requests and pushes to main/master branches |
| 9 | +- Builds the project using TypeScript, Webpack, and Rollup |
| 10 | +- Verifies that all build artifacts are created successfully |
| 11 | +- Does not publish to NPM |
| 12 | + |
| 13 | +### Build and Publish (`publish.yml`) |
| 14 | +- Runs when a new version tag is pushed (e.g., `v0.0.4`) |
| 15 | +- Verifies that the tag version matches the package.json version |
| 16 | +- Builds the project and all bundles |
| 17 | +- Publishes the package to NPM |
| 18 | + |
| 19 | +## Setup |
| 20 | + |
| 21 | +### NPM Token Setup |
| 22 | + |
| 23 | +To enable automatic publishing to NPM, you need to set up an NPM authentication token: |
| 24 | + |
| 25 | +1. **Create an NPM Access Token:** |
| 26 | + - Go to [npmjs.com](https://www.npmjs.com) and log in |
| 27 | + - Navigate to your profile settings |
| 28 | + - Go to "Access Tokens" section |
| 29 | + - Click "Generate New Token" |
| 30 | + - Select "Automation" token type |
| 31 | + - Copy the generated token |
| 32 | + |
| 33 | +2. **Add the Token to GitHub Secrets:** |
| 34 | + - Go to your GitHub repository |
| 35 | + - Navigate to Settings → Secrets and variables → Actions |
| 36 | + - Click "New repository secret" |
| 37 | + - Name: `NPM_TOKEN` |
| 38 | + - Value: Paste your NPM access token |
| 39 | + - Click "Add secret" |
| 40 | + |
| 41 | +### Publishing Process |
| 42 | + |
| 43 | +1. **Prepare for Release:** |
| 44 | + - Update the version in `package.json` |
| 45 | + - Commit your changes |
| 46 | + - Push to the repository |
| 47 | + |
| 48 | +2. **Create and Push Version Tag:** |
| 49 | + ```bash |
| 50 | + git tag v0.0.4 |
| 51 | + git push origin v0.0.4 |
| 52 | + ``` |
| 53 | + |
| 54 | + Or create the tag via GitHub: |
| 55 | + - Go to GitHub repository → Releases |
| 56 | + - Click "Create a new release" |
| 57 | + - Tag version (e.g., `v0.0.4`) |
| 58 | + - Write release notes |
| 59 | + - Click "Publish release" |
| 60 | + |
| 61 | +3. **Automatic Publishing:** |
| 62 | + - The `publish.yml` workflow will automatically trigger when the tag is pushed |
| 63 | + - It will verify the version matches package.json |
| 64 | + - Build the project and publish to NPM |
| 65 | + - Check the Actions tab to monitor the process |
| 66 | + |
| 67 | +## Build Process |
| 68 | + |
| 69 | +The build process includes: |
| 70 | + |
| 71 | +1. **TypeScript Compilation:** `npm run build` |
| 72 | +2. **Browser Bundle:** Webpack creates `dist/ccxt.browser.js` |
| 73 | +3. **CommonJS Bundle:** Rollup creates `dist/cjs/` directory |
| 74 | +4. **Minified Bundle:** Production webpack build |
| 75 | + |
| 76 | +## Troubleshooting |
| 77 | + |
| 78 | +- **Build Failures:** Check the Actions tab for detailed error logs |
| 79 | +- **NPM Publishing Issues:** Verify the NPM_TOKEN secret is correctly set |
| 80 | +- **Version Conflicts:** The workflow will automatically fail if the tag version doesn't match package.json version |
| 81 | +- **Tag Format:** Ensure tags follow the format `v*` (e.g., `v0.0.4`, `v1.2.3`) |
0 commit comments