chore(deps): lock file maintenance #106
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: CD | |
on: | |
push: | |
branches: | |
- master | |
jobs: | |
unit-test: | |
name: Test | |
runs-on: ${{ matrix.config.os }} # we run many different builds | |
strategy: | |
matrix: | |
config: | |
- os: ubuntu-latest | |
- os: macos-latest | |
- os: windows-latest | |
steps: | |
- name: Get yarn cache directory path | |
id: yarn-cache-dir-path | |
run: echo "::set-output name=dir::$(yarn cache dir)" | |
- uses: actions/cache@v2 | |
id: yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`) | |
with: | |
path: ${{ steps.yarn-cache-dir-path.outputs.dir }} | |
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }} | |
restore-keys: | | |
${{ runner.os }}-yarn- | |
- uses: actions/checkout@v2 | |
- uses: actions/setup-node@v2 | |
with: | |
node-version: '16' | |
- run: yarn | |
- run: yarn format-check | |
- run: yarn test-compile | |
- run: yarn compile | |
# https://github.com/GabrielBB/xvfb-action | |
- name: Run headless test | |
uses: GabrielBB/xvfb-action@v1 | |
with: | |
run: yarn test | |
release: | |
name: release | |
runs-on: ubuntu-latest | |
needs: unit-test | |
steps: | |
- name: Get yarn cache directory path | |
id: yarn-cache-dir-path | |
run: echo "::set-output name=dir::$(yarn cache dir)" | |
- uses: actions/cache@v2 | |
id: yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`) | |
with: | |
path: ${{ steps.yarn-cache-dir-path.outputs.dir }} | |
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }} | |
restore-keys: | | |
${{ runner.os }}-yarn- | |
- uses: actions/checkout@v2 | |
- uses: actions/setup-node@v2 | |
with: | |
node-version: '16' | |
- name: read version | |
run: | | |
PACKAGE_VERSION=$(node -p "require('./package.json').version") | |
echo "PACKAGE_VERSION=$PACKAGE_VERSION" >> $GITHUB_ENV | |
echo "PACKAGE_VERSION=$PACKAGE_VERSION" | |
PUBLISHED_VERSION=$(curl 'https://marketplace.visualstudio.com/_apis/public/gallery/extensionquery' \ | |
-H 'origin: https://marketplace.visualstudio.com' \ | |
-H 'pragma: no-cache' \ | |
-H 'user-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/74.0.3729.108 Safari/537.36' \ | |
-H 'content-type: application/json' \ | |
-H 'accept: application/json;api-version=5.1-preview.1;excludeUrls=true' \ | |
-H 'cache-control: no-cache' \-H 'authority: marketplace.visualstudio.com' \ | |
-H 'referer: https://marketplace.visualstudio.com/items?itemName=foxundermoon.shell-format' \ | |
--data-binary '{"assetTypes":null,"filters":[{"criteria":[{"filterType":7,"value":"foxundermoon.shell-format"}],"direction":2,"pageSize":1,"pageNumber":1,"sortBy":0,"sortOrder":0,"pagingToken":null}],"flags":71}' | | |
jq '.results[0].extensions[0].versions[0].version') | |
echo "PUBLISHED_VERSION=$PUBLISHED_VERSION" | |
if [ "$PACKAGE_VERSION" = "$PUBLISHED_VERSION" ]; then | |
echo 'niddend published' | |
echo "NEED_RELEASE=no" >> $GITHUB_ENV | |
else | |
echo "need publish" | |
echo "NEED_RELEASE=yes" >> $GITHUB_ENV | |
fi | |
- run: yarn | |
if: env.NEED_RELEASE == 'yes' | |
- name: mini changelog | |
if: env.NEED_RELEASE == 'yes' | |
id: minichangelog | |
run: | | |
VERSION_REGEX="## $(echo ${{ env.PACKAGE_VERSION }} | sed 's/\./\\./g')" | |
sed -n "/$VERSION_REGEX/,/## /p" CHANGELOG.md | sed '$d' > minichangelog.txt | |
cat minichangelog.txt | |
# echo "::set-output name=minichangelog::$(cat minichangelog.txt) | |
echo "MINI_CHANGELOG<<EOF" >> $GITHUB_ENV | |
cat minichangelog.txt >> $GITHUB_ENV | |
echo "EOF" >> $GITHUB_ENV | |
- name: check changelog | |
if: env.NEED_RELEASE == 'yes' | |
run: | | |
LINE_COUNT=$(cat minichangelog.txt | wc -l) | |
if [ "$LINE_COUNT" -lt 3 ]; then | |
echo Mini changelog is too short. Did you use the wrong version number in CHANGELOG.txt? | |
exit 1 | |
fi | |
- name: package | |
if: env.NEED_RELEASE == 'yes' | |
run: | | |
yarn package | |
echo FILE_NAME=$(node -p "require('./package.json').name")-${{ env.PACKAGE_VERSION }}.vsix >> $GITHUB_ENV | |
- name: create github release | |
if: env.NEED_RELEASE == 'yes' | |
id: create_release | |
uses: actions/create-release@master | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # This token is provided by Actions, you do not need to create your own token | |
with: | |
tag_name: ${{ env.PACKAGE_VERSION }} | |
release_name: Release ${{ env.PACKAGE_VERSION }} | |
body: | | |
${{ env.MINI_CHANGELOG }} | |
draft: false | |
prerelease: false | |
- name: Upload Release Asset | |
if: env.NEED_RELEASE == 'yes' | |
id: upload-release-asset | |
uses: actions/[email protected] | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
upload_url: ${{ steps.create_release.outputs.upload_url }} # This pulls from the CREATE RELEASE step above, referencing it's ID to get its outputs object, which include a `upload_url`. See this blog post for more info: https://jasonet.co/posts/new-features-of-github-actions/#passing-data-to-future-steps | |
asset_path: ./${{ env.FILE_NAME }} | |
asset_name: ${{ env.FILE_NAME }} | |
asset_content_type: application/gzip | |
- name: Vscode release plugin | |
if: env.NEED_RELEASE == 'yes' | |
run: | | |
yarn vsce publish -p ${{ secrets.PUBLISHER_TOKEN }} |