diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index cb17c44..0eb33b8 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -19,7 +19,7 @@ jobs: - uses: actions/checkout@v3 - uses: actions/setup-node@v2 with: - node-version: 16 + node-version: 18 - run: npm install - run: npm test @@ -29,6 +29,6 @@ jobs: - uses: actions/checkout@v3 - uses: actions/setup-node@v2 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..4989bcc --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,84 @@ +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-tablegen + + - name: Checkout Repository + if: ${{ steps.release.outputs.releases_created }} + uses: actions/checkout@v3 + + - name: Extract version + id: extract_version + run: | + PR_TITLE="${{ github.event.pull_request.title }}" + VERSION=$(echo "$PR_TITLE" | grep -oP '(?<=release ).*$') + echo "::set-output name=version::$VERSION" + - name: Update Rust README version + run: | + version="${{ steps.extract_version.outputs.version }}" + repo_name="${{ github.repository }}" + repo_name="${repo_name##*/}" + + git config user.name github-actions[bot] + git config user.email github-actions[bot]@users.noreply.github.com + git fetch origin master + git checkout master + + sed -i "s/$repo_name = \"[^\"]*\"/$repo_name = \"$version\"/g" bindings/rust/README.md + + git add package.json Cargo.toml bindings/rust/README.md + git commit -m "chore(manifests): bump version to $version" + git push https://${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }}.git HEAD:master + + - name: Setup Node + uses: actions/setup-node@v3 + if: ${{ steps.release.outputs.releases_created }} + with: + node-version: 18 + registry-url: "https://registry.npmjs.org" + - name: Publish to NPM + if: ${{ steps.release.outputs.releases_created }} + 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 + if: ${{ steps.release.outputs.release_created }} + 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..e18ee07 --- /dev/null +++ b/.release-please-manifest.json @@ -0,0 +1,3 @@ +{ + ".": "0.0.0" +} diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..e69de29 diff --git a/release-please-config.json b/release-please-config.json new file mode 100644 index 0000000..3e82c4a --- /dev/null +++ b/release-please-config.json @@ -0,0 +1,13 @@ +{ + "packages": { + ".": { + "changelog-path": "CHANGELOG.md", + "release-type": ["node", "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" +}