diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index cb17c44..3c46136 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -17,9 +17,9 @@ jobs: os: [macos-latest, ubuntu-latest] steps: - uses: actions/checkout@v3 - - uses: actions/setup-node@v2 + - uses: actions/setup-node@v3 with: - node-version: 16 + node-version: 18 - run: npm install - run: npm test @@ -27,8 +27,8 @@ jobs: runs-on: windows-2019 steps: - uses: actions/checkout@v3 - - uses: actions/setup-node@v2 + - uses: actions/setup-node@v3 with: - node-version: 16 + node-version: 18 - run: npm install - run: npm run-script test-windows diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml deleted file mode 100644 index 27632c9..0000000 --- a/.github/workflows/publish.yml +++ /dev/null @@ -1,51 +0,0 @@ -name: Publish - -on: - push: - branches: - - master - tags: - - "v*" - workflow_dispatch: - -jobs: - build: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - - uses: actions/setup-node@v3 - with: - node-version: 16 - - run: npm install - - run: npm test - - publish-npm: - if: startsWith(github.ref, 'refs/tags/v') - needs: build - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v3 - - uses: actions/setup-node@v3 - with: - node-version: 16 - registry-url: https://registry.npmjs.org/ - - run: npm install - - run: npm publish - env: - NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}} - - publish-crates: - if: startsWith(github.ref, 'refs/tags/v') - needs: build - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - - uses: actions-rs/toolchain@v1 - with: - profile: minimal - toolchain: stable - override: true - - uses: katyo/publish-crates@v2 - with: - registry-token: ${{ secrets.CARGO_REGISTRY_TOKEN }} diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..2603e56 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,95 @@ +name: Release + +on: + workflow_run: + workflows: ["CI"] + types: + - completed + +permissions: + contents: write + pull-requests: write + +jobs: + release: + runs-on: ubuntu-latest + if: ${{ github.event.workflow_run.conclusion == 'success' }} + steps: + - uses: google-github-actions/release-please-action@v3 + id: release + with: + command: manifest + token: ${{ secrets.GITHUB_TOKEN }} + package-name: tree-sitter-capnp + + - name: Checkout Repository + if: ${{ steps.release.outputs.releases_created }} + uses: actions/checkout@v3 + + update-readme: + runs-on: ubuntu-latest + if: contains(github.event.pull_request.labels.*.name, 'autorelease:\ pending') + needs: release + steps: + - uses: actions/checkout@v3 + with: + ref: ${{ github.event.pull_request.head.ref }} + token: ${{ secrets.GITHUB_TOKEN }} + + - name: Extract version from Cargo.toml + id: cargo-version + run: | + echo "::set-output name=version::$(grep '^version =' Cargo.toml | cut -d'"' -f2)" + + - name: Update Rust README version + run: | + repo_name="${{ github.repository }}" + repo_name="${repo_name##*/}" + version="${{ steps.cargo-version.outputs.version }}" + + git config user.name github-actions[bot] + git config user.email github-actions[bot]@users.noreply.github.com + + sed -i "s/$repo_name = \"[^\"]*\"/$repo_name = \"$version\"/g" bindings/rust/README.md + + - name: Amend and push changes + run: | + git add . + git commit --amend --no-edit + git push -f + + publish: + runs-on: ubuntu-latest + needs: update-readme + if: ${{ steps.release.outputs.releases_created }} + steps: + - name: Setup Node + uses: actions/setup-node@v3 + with: + node-version: 18 + registry-url: "https://registry.npmjs.org" + - name: Publish to NPM + env: + NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}} + run: npm publish + + - name: Setup Rust + uses: actions-rs/toolchain@v1 + with: + profile: minimal + toolchain: stable + override: true + - name: Publish to Crates.io + uses: katyo/publish-crates@v2 + with: + registry-token: ${{ secrets.CARGO_REGISTRY_TOKEN }} + + - name: Tag stable versions + run: | + git config user.name github-actions[bot] + git config user.email github-actions[bot]@users.noreply.github.com + git remote add gh-token "https://${{ secrets.GITHUB_TOKEN }}@github.com/google-github-actions/release-please-action.git" + git tag -d stable || true + git push origin :stable || true + git tag -a stable -m "Last Stable Release" + git push origin stable diff --git a/.release-please-manifest.json b/.release-please-manifest.json new file mode 100644 index 0000000..cc3471b --- /dev/null +++ b/.release-please-manifest.json @@ -0,0 +1,4 @@ +{ + ".": "1.4.0", + "./": "1.4.0" +} diff --git a/Cargo.toml b/Cargo.toml index d878454..71f8349 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,15 +1,15 @@ [package] name = "tree-sitter-capnp" -description = "Cap'n Proto grammar for tree-sitter" version = "1.4.0" authors = ["Amaan Qureshi "] +autoexamples = false +categories = ["parsing", "text-editors"] +edition = "2021" +keywords = ["incremental", "parsing", "capnp"] license = "MIT" readme = "bindings/rust/README.md" -keywords = ["incremental", "parsing", "capnp"] -categories = ["parsing", "text-editors"] repository = "https://github.com/amaanq/tree-sitter-capnp" -edition = "2021" -autoexamples = false +description = "Cap'n Proto grammar for tree-sitter" build = "bindings/rust/build.rs" include = ["bindings/rust/*", "grammar.js", "queries/*", "src/*"] diff --git a/release-please-config.json b/release-please-config.json new file mode 100644 index 0000000..9864b74 --- /dev/null +++ b/release-please-config.json @@ -0,0 +1,20 @@ +{ + "packages": { + ".": { + "changelog-path": "CHANGELOG.md", + "release-type": "node", + "bump-minor-pre-major": false, + "bump-patch-for-minor-pre-major": false, + "draft": false, + "prerelease": false + }, + "./": { + "release-type": "rust", + "bump-minor-pre-major": false, + "bump-patch-for-minor-pre-major": false, + "draft": false, + "prerelease": false + } + }, + "$schema": "https://raw.githubusercontent.com/googleapis/release-please/main/schemas/config.json" +}