update #15
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: NodeJS with Webpack | |
on: | |
push: | |
branches: [ main ] | |
pull_request: | |
branches: [ main ] | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
node-version: [14.x] | |
steps: | |
- uses: actions/checkout@v2 | |
- name: Set latest release version | |
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: Use Node.js ${{ matrix.node-version }} | |
uses: actions/setup-node@v1 | |
with: | |
node-version: ${{ matrix.node-version }} | |
- name: Build | |
run: | | |
yarn | |
yarn build | |
- name: Pack build result | |
run: | | |
sudo apt-get install zip | |
zip -r hj3-web-${{steps.set_version.outputs.result}}.zip build/* | |
- name: Upload build result | |
uses: actions/[email protected] | |
with: | |
path: hj3-web-${{steps.set_version.outputs.result}}.zip | |
- name: Publish | |
uses: softprops/action-gh-release@v1 | |
with: | |
files: | | |
hj3-web-${{steps.set_version.outputs.result}}.zip | |
prerelease: false | |
tag_name: ${{steps.set_version.outputs.result}} | |
generate_release_notes: true | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |