Skip to content

Commit

Permalink
feat: use release-please
Browse files Browse the repository at this point in the history
  • Loading branch information
amaanq committed Jul 13, 2023
1 parent 7d5fa4e commit 6cf0b34
Show file tree
Hide file tree
Showing 6 changed files with 128 additions and 60 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,18 @@ 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

test_windows:
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
51 changes: 0 additions & 51 deletions .github/workflows/publish.yml

This file was deleted.

103 changes: 103 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
name: Release

# on:
# workflow_run:
# workflows: ["CI"]
# types:
# - completed
on:
push:
branches:
- master

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

update-readme:
runs-on: ubuntu-latest
needs: release
steps:
- uses: actions/checkout@v3
with:
token: ${{ secrets.GITHUB_TOKEN }}

- name: Extract version from package.json
id: package-version
run: |
echo "::set-output name=version::$(grep -o '"version": *"[^"]*"' package.json | sed 's/"version": "\(.*\)"/\1/')"
- name: Update Rust version
run: |
repo_name="${{ github.repository }}"
repo_name="${repo_name##*/}"
version="${{ steps.package-version.outputs.version }}"
git fetch origin release-please--branches--master--components--tree-sitter-capnp
git checkout release-please--branches--master--components--tree-sitter-capnp
git config user.name github-actions[bot]
git config user.email github-actions[bot]@users.noreply.github.com
sed -i "s/version = \"[^\"]*\"/version = \"$version\"/g" Cargo.toml
sed -i "s/$repo_name = \"[^\"]*\"/$repo_name = \"$version\"/g" bindings/rust/README.md
echo "version set to: $version"
git log -n5
git rev-parse HEAD
cat package.json
git status
git add Cargo.toml bindings/rust/README.md
git status
git commit -m test
git push -f
publish:
runs-on: ubuntu-latest
needs: [release, update-readme]
if: ${{ needs.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
3 changes: 3 additions & 0 deletions .release-please-manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
".": "1.4.0"
}
10 changes: 5 additions & 5 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
[package]
name = "tree-sitter-capnp"
description = "Cap'n Proto grammar for tree-sitter"
version = "1.4.0"
authors = ["Amaan Qureshi <amaanq12@gmail.com>"]
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/*"]
Expand Down
13 changes: 13 additions & 0 deletions release-please-config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"packages": {
".": {
"changelog-path": "CHANGELOG.md",
"release-type": "node",
"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"
}

0 comments on commit 6cf0b34

Please sign in to comment.