cicd: new workflow
This commit is contained in:
parent
1b1c3974f7
commit
cc4f932d17
14 changed files with 611 additions and 228 deletions
101
.github/workflows/release.yml
vendored
Normal file
101
.github/workflows/release.yml
vendored
Normal file
|
|
@ -0,0 +1,101 @@
|
|||
name: Release
|
||||
|
||||
on:
|
||||
workflow_call:
|
||||
inputs:
|
||||
ref:
|
||||
default: ${{ github.ref }}
|
||||
type: string
|
||||
|
||||
jobs:
|
||||
permissions:
|
||||
name: Check permissions
|
||||
runs-on: ubuntu-latest
|
||||
outputs:
|
||||
release_allowed: ${{ steps.maintainer.outputs.is_maintainer == 'true' }}
|
||||
steps:
|
||||
|
||||
- name: Is maintainer
|
||||
id: maintainer
|
||||
env:
|
||||
GH_TOKEN: ${{ github.token }}
|
||||
repo: ${{ github.repository }}
|
||||
actor: ${{ github.actor }}
|
||||
run: |
|
||||
maintainer=$(
|
||||
gh api "/repos/${repo}/collaborators" |
|
||||
jq ".[] | {login, maintainer: .permissions | .maintain} | select(.login == \"${actor}\") | .maintainer"
|
||||
);
|
||||
if [ "$maintainer" == "true" ]; then
|
||||
echo "@${actor} has maintainer level permissions :rocket:" >> $GITHUB_STEP_SUMMARY;
|
||||
echo "is_maintainer=true" >> $GITHUB_OUTPUT
|
||||
fi
|
||||
|
||||
release:
|
||||
name: Release
|
||||
needs: permissions
|
||||
if: needs.permissions.outputs.release_allowed
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
contents: write
|
||||
steps:
|
||||
|
||||
- name: Checkout source code
|
||||
uses: actions/checkout@v3
|
||||
with:
|
||||
ref: ${{ inputs.ref }}
|
||||
|
||||
- name: Download build artifacts
|
||||
uses: actions/download-artifact@v3
|
||||
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); do
|
||||
exe=$(ls artifacts/$platform/tree-sitter*)
|
||||
gzip --stdout --name $exe > target/tree-sitter-$platform.gz
|
||||
done
|
||||
rm -rf artifacts
|
||||
ls -l target/
|
||||
|
||||
- name: Get tag name from a release/v* branch name
|
||||
id: tag_name
|
||||
env:
|
||||
tag: ${{ github.head_ref }}
|
||||
run: echo "tag=${tag#release/}" >> $GITHUB_OUTPUT
|
||||
|
||||
- name: Add a release tag
|
||||
env:
|
||||
ref: ${{ inputs.ref }}
|
||||
tag: ${{ steps.tag_name.outputs.tag }}
|
||||
message: "Release ${{ steps.tag_name.outputs.tag }}"
|
||||
run: |
|
||||
git config user.name "${GITHUB_ACTOR}"
|
||||
git config user.email "${GITHUB_ACTOR}@users.noreply.github.com"
|
||||
git tag -a "$tag" HEAD -m "$message"
|
||||
git push origin "$tag"
|
||||
|
||||
- name: Create release
|
||||
uses: softprops/action-gh-release@v1
|
||||
with:
|
||||
name: ${{ steps.tag_name.outputs.tag }}
|
||||
tag_name: ${{ steps.tag_name.outputs.tag }}
|
||||
fail_on_unmatched_files: true
|
||||
files: |
|
||||
tree-sitter-*.gz
|
||||
tree-sitter.wasm
|
||||
tree-sitter.js
|
||||
|
||||
- name: Merge release PR
|
||||
env:
|
||||
GH_TOKEN: ${{ github.token }}
|
||||
run: |
|
||||
gh pr merge ${{ github.event.pull_request.html_url }} --match-head-commit $(git rev-parse HEAD) --merge --delete-branch
|
||||
Loading…
Add table
Add a link
Reference in a new issue