update file #5
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Build and publish | |
on: | |
push: | |
branches: "master" | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
if: "!contains(github.event.head_commit.message, '[skip ci]') && !contains(github.event.head_commit.message, '[ci skip]')" | |
strategy: | |
matrix: | |
target: [ x86_64-unknown-linux-gnu ] | |
steps: | |
- uses: actions/checkout@v3 | |
with: | |
submodules: 'recursive' | |
- name: Set latest release version | |
if: github.event_name == 'push' && github.ref == 'refs/heads/master' | |
id: set_version | |
uses: actions/github-script@v6 | |
with: | |
result-encoding: string | |
script: | | |
const { data: releases } = await github.rest.repos.listReleases({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
}); | |
const { data: tags } = await github.rest.repos.listTags({ | |
owner: context.repo.owner, | |
repo: context.repo.repo | |
}); | |
if (releases.length === 0) { return "v0.0.1"; } | |
function increase_v(version) { | |
const parts = version.split("."); | |
const last = parseInt(parts[2]) + 1; | |
const next_version = `${parts[0]}.${parts[1]}.${last.toString()}`; | |
return next_version; | |
} | |
const latest_release_tag = releases[0].tag_name; | |
const tag = tags.find(tag => tag.commit.sha === context.sha); | |
return tag ? tag.name : increase_v(latest_release_tag) | |
- name: install deps | |
run: | | |
sudo apt-get install -y --no-install-recommends \ | |
libelf1 libelf-dev zlib1g-dev libclang-13-dev \ | |
make git clang llvm pkg-config build-essential | |
- name: build package | |
run: make build | |
- name: Publish | |
if: github.event_name == 'push' && github.ref == 'refs/heads/master' | |
uses: softprops/action-gh-release@v1 | |
with: | |
files: | | |
src/bootstrap | |
prerelease: false | |
tag_name: ${{ steps.set_version.outputs.result }} | |
generate_release_notes: true | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |