Merge pull request #2 from lancard/dependabot/npm_and_yarn/follow-red… #236
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 | |
on: | |
push: | |
branches: [ "master" ] | |
pull_request: | |
branches: [ "master" ] | |
workflow_dispatch: | |
jobs: | |
build: | |
permissions: write-all | |
runs-on: windows-latest | |
steps: | |
- name: Check out Git repository | |
uses: actions/checkout@v1 | |
- name: Install Node.js, NPM and Yarn | |
uses: actions/setup-node@v1 | |
with: | |
node-version: 16 | |
- name: Get version from package.json | |
run: node -p "'VERSION_STRING='+require('./package.json').version" >> $env:GITHUB_ENV | |
- name: Get previous version from version.txt | |
run: echo ("PREVIOUS_VERSION_STRING="+(Invoke-WebRequest -Uri "https://lancard.github.io/k-installer/version.txt").Content.Trim()) >> $env:GITHUB_ENV | |
# pass generate exe when version not changed | |
- if: env.PREVIOUS_VERSION_STRING != env.VERSION_STRING | |
run: npm install | |
- if: env.PREVIOUS_VERSION_STRING != env.VERSION_STRING | |
run: npm run package | |
- name: Compress exe | |
if: env.PREVIOUS_VERSION_STRING != env.VERSION_STRING | |
run: compress-archive -path ".\dist\k-installer Setup ${{ env.VERSION_STRING }}.exe" "k-installer.zip" -compressionlevel optimal | |
- name: Create Release | |
if: env.PREVIOUS_VERSION_STRING != env.VERSION_STRING | |
id: create_release | |
uses: actions/create-release@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # This token is provided by Actions, you do not need to create your own token | |
with: | |
tag_name: v${{ env.VERSION_STRING }} | |
release_name: Release v${{ env.VERSION_STRING }} | |
draft: false | |
prerelease: false | |
- name: Upload Setup exe file | |
if: env.PREVIOUS_VERSION_STRING != env.VERSION_STRING | |
uses: actions/upload-release-asset@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # This token is provided by Actions, you do not need to create your own token | |
with: | |
upload_url: ${{ steps.create_release.outputs.upload_url }} | |
asset_path: k-installer.zip | |
asset_name: k-installer.zip | |
asset_content_type: application/zip | |
# Setup pages | |
- name: Setup Pages | |
uses: actions/configure-pages@v3 | |
- name: Generate Version File | |
run: echo "${{ env.VERSION_STRING }}" > resources/version.txt | |
- name: Copy package.json | |
run: cp package.json resources/ | |
- name: Upload artifact | |
uses: actions/upload-pages-artifact@v1 | |
with: | |
path: './resources' | |
- name: Deploy to GitHub Pages | |
id: deployment | |
uses: actions/deploy-pages@v2 |