Skip to content

Commit

Permalink
chore: use release-please
Browse files Browse the repository at this point in the history
  • Loading branch information
amaanq committed Jul 13, 2023
1 parent a0626d4 commit 300f6a4
Show file tree
Hide file tree
Showing 6 changed files with 102 additions and 53 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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

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

This file was deleted.

84 changes: 84 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -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
3 changes: 3 additions & 0 deletions .release-please-manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
".": "0.0.0"
}
Empty file added CHANGELOG.md
Empty file.
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", "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"
}

0 comments on commit 300f6a4

Please sign in to comment.