diff --git a/.github/release-please-config.json b/.github/release-please-config.json new file mode 100644 index 0000000..d8f2a88 --- /dev/null +++ b/.github/release-please-config.json @@ -0,0 +1,8 @@ +{ + "packages": { + ".": { + "package-name": "react-i18next-helpers", + "release-type": "node" + } + } +} diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..ac91afb --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,34 @@ +name: CI + +on: + push: + branches: + - main + pull_request: + branches: + - main + +jobs: + test: + name: Build package + runs-on: ubuntu-latest + steps: + - name: Check out repository + uses: actions/checkout@v4 + + - name: Set up Node.js + uses: actions/setup-node@v4 + with: + node-version: 22.14.0 + + - name: Install Yarn + run: npm install --global yarn@1.22.22 + + - name: Install dependencies + run: yarn install --frozen-lockfile --ignore-engines + + - name: Build package + run: npm run prepublishOnly + + - name: Check package contents + run: npm pack --dry-run diff --git a/.github/workflows/publish-npm.yml b/.github/workflows/publish-npm.yml new file mode 100644 index 0000000..0937187 --- /dev/null +++ b/.github/workflows/publish-npm.yml @@ -0,0 +1,98 @@ +name: Publish npm package + +on: + pull_request: + push: + branches: + - main + +permissions: + contents: read + id-token: write + +jobs: + validate-pr-and-release: + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Setup Node.js + uses: actions/setup-node@v4 + with: + node-version: 22.14.0 + + - name: Upgrade npm and install Yarn + run: npm install --global npm@11.5.1 yarn@1.22.22 + + - name: Verify npm version + run: npm --version + + - name: Install dependencies + run: yarn install --frozen-lockfile --ignore-engines + + - name: Build package + run: npm run prepublishOnly + + - name: Check package contents + run: npm pack --dry-run + + release-please-on-main: + if: github.event_name == 'push' + needs: validate-pr-and-release + runs-on: ubuntu-latest + permissions: + contents: write + pull-requests: write + outputs: + release_created: ${{ steps.release.outputs.release_created }} + version: ${{ steps.release.outputs.version }} + steps: + - name: Checkout repository + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Create release PR or tag + id: release + uses: googleapis/release-please-action@v4 + with: + token: ${{ secrets.GITHUB_TOKEN }} + config-file: .github/release-please-config.json + manifest-file: .release-please-manifest.json + + publish-release: + if: needs.release-please-on-main.outputs.release_created == 'true' + needs: release-please-on-main + runs-on: ubuntu-latest + permissions: + contents: read + id-token: write + steps: + - name: Checkout repository + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Setup Node.js + uses: actions/setup-node@v4 + with: + node-version: 22.14.0 + registry-url: https://registry.npmjs.org + + - name: Upgrade npm and install Yarn + run: npm install --global npm@11.5.1 yarn@1.22.22 + + - name: Verify npm version + run: npm --version + + - name: Install dependencies + run: yarn install --frozen-lockfile --ignore-engines + + - name: Build package + run: npm run prepublishOnly + + - name: Publish to npm + run: npm publish --provenance --access public diff --git a/.release-please-manifest.json b/.release-please-manifest.json new file mode 100644 index 0000000..37fcefa --- /dev/null +++ b/.release-please-manifest.json @@ -0,0 +1,3 @@ +{ + ".": "1.0.0" +}