Switch the release trigger from PR to a git tag. In practice this would mean tagging a commit in master branch and pushing it with `git push --tags`. The benefit of this is that tagging is already an event that is reserved for maintainers, so we can remove the need for verifying whether the event was done by a maintainer. We also no longer need to keep track of the tag. Previously the trigger was a PR which has a different ref from the tag, so manual bookkeeping was required to ensure github used the tag reference instead of the PR reference. Having the tagging itself be the trigger removes this need entirely as the default checkout will already use the tag as reference.
96 lines
2.3 KiB
YAML
96 lines
2.3 KiB
YAML
name: Release
|
|
on:
|
|
workflow_dispatch:
|
|
push:
|
|
tags:
|
|
- v*
|
|
|
|
jobs:
|
|
build:
|
|
uses: ./.github/workflows/build.yml
|
|
with:
|
|
run_test: false
|
|
|
|
release:
|
|
name: Release
|
|
runs-on: ubuntu-latest
|
|
needs: build
|
|
permissions:
|
|
contents: write
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
|
|
- name: Download build artifacts
|
|
uses: actions/download-artifact@v4
|
|
with:
|
|
path: artifacts
|
|
|
|
- name: Display structure of downloaded files
|
|
run: ls -lR
|
|
working-directory: artifacts
|
|
|
|
- name: Prepare release artifacts
|
|
run: |
|
|
mkdir -p target
|
|
mv artifacts/tree-sitter.wasm/* target/
|
|
rm -r artifacts/tree-sitter.wasm
|
|
for platform in $(cd artifacts; ls | sed 's/^tree-sitter\.//'); do
|
|
exe=$(ls artifacts/tree-sitter.$platform/tree-sitter*)
|
|
gzip --stdout --name $exe > target/tree-sitter-$platform.gz
|
|
done
|
|
rm -rf artifacts
|
|
ls -l target/
|
|
|
|
- name: Create release
|
|
uses: softprops/action-gh-release@v1
|
|
with:
|
|
name: ${{ github.ref_name }}
|
|
tag_name: ${{ github.ref_name }}
|
|
fail_on_unmatched_files: true
|
|
files: |
|
|
target/tree-sitter-*.gz
|
|
target/tree-sitter.wasm
|
|
target/tree-sitter.js
|
|
|
|
crates_io:
|
|
name: Publish CLI to Crates.io
|
|
runs-on: ubuntu-latest
|
|
needs: release
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
|
|
- name: Setup Rust
|
|
uses: actions-rs/toolchain@v1
|
|
with:
|
|
profile: minimal
|
|
toolchain: stable
|
|
override: true
|
|
|
|
- name: Publish CLI to Crates.io
|
|
uses: katyo/publish-crates@v2
|
|
with:
|
|
registry-token: ${{ secrets.CARGO_REGISTRY_TOKEN }}
|
|
|
|
npm:
|
|
name: Publish lib to npmjs.com
|
|
runs-on: ubuntu-latest
|
|
needs: release
|
|
strategy:
|
|
fail-fast: false
|
|
matrix:
|
|
directory: ["cli/npm", "lib/binding_web"]
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
|
|
- name: Setup Node
|
|
uses: actions/setup-node@v4
|
|
with:
|
|
node-version: 18
|
|
registry-url: "https://registry.npmjs.org"
|
|
|
|
- name: Publish lib to npmjs.com
|
|
env:
|
|
NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}
|
|
run: |
|
|
cd ${{ matrix.directory }}
|
|
npm publish
|