v3.4.2 #70
Workflow file for this run
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: CI-prerelease | |
on: | |
push: | |
branches: | |
- prerelease | |
paths-ignore: | |
- "docs/**" | |
- ".vscode/**" | |
- ".github/**" | |
- "*.md" | |
- "**/*.md" | |
pull_request: | |
branches: | |
- prerelease | |
release: | |
types: | |
- released | |
jobs: | |
build: | |
timeout-minutes: 10 | |
runs-on: ${{ matrix.os }} | |
strategy: | |
matrix: | |
os: [ubuntu-latest, windows-latest, macOS-latest] | |
outputs: | |
name: ${{ steps.set-version.outputs.name }} | |
version: ${{ steps.set-version.outputs.version }} | |
taggedbranch: ${{ steps.find-branch.outputs.taggedbranch }} | |
steps: | |
- uses: actions/checkout@v2 | |
- run: git fetch --depth=1 origin +refs/tags/*:refs/tags/* | |
- name: Find which branch the release tag points at | |
id: find-branch | |
if: github.event_name == 'release' && runner.os == 'Windows' | |
shell: bash | |
run: | | |
git fetch --depth=1 origin +refs/heads/*:refs/heads/* | |
set -x | |
TAGGEDBRANCH=$(git for-each-ref --points-at=${{github.sha}} --format='%(refname:lstrip=2)' refs/heads/) | |
echo ::set-output name=taggedbranch::$TAGGEDBRANCH | |
- name: Set an output | |
id: set-version | |
if: runner.os == 'Windows' | |
shell: bash | |
run: | | |
set -x | |
VERSION=$(jq -r '.version' package.json | cut -d- -f1) | |
[ $GITHUB_EVENT_NAME == 'release' ] && VERSION=${{ github.event.release.tag_name }} && VERSION=${VERSION/v/} | |
CHANGELOG=$(cat CHANGELOG.md | sed -n "/## \[${VERSION}\]/,/## /p" | sed '/^$/d;1d;$d') | |
CHANGELOG="${CHANGELOG//$'\n'/'%0A'}" | |
echo ::set-output name=changelog::$CHANGELOG | |
git tag -l | cat | |
[ $GITHUB_EVENT_NAME == 'push' ] && VERSION+=-beta && VERSION+=.$(($(git tag -l "v$VERSION.*" | sort -nt. -k4 2>/dev/null | tail -1 | cut -d. -f4)+1)) | |
[ $GITHUB_EVENT_NAME == 'pull_request' ] && VERSION+=-dev.${{ github.event.pull_request.number }} | |
echo ::set-output name=version::$VERSION | |
NAME=$(jq -r '.name' package.json)-$VERSION | |
echo ::set-output name=name::$NAME | |
tmp=$(mktemp) | |
jq --arg version "$VERSION" '.version = $version' package.json > "$tmp" && mv "$tmp" package.json | |
mkdir dist | |
echo $VERSION > .version | |
echo $NAME > .name | |
- name: Use Node.js | |
uses: actions/setup-node@v1 | |
with: | |
node-version: 14.x | |
- run: npm install | |
- run: npm run compile | |
- name: npm test | |
uses: GabrielBB/xvfb-action@v1.0 | |
with: | |
run: npm run test | |
- name: Build pre-release package | |
if: runner.os == 'Windows' | |
run: | | |
npx vsce package --pre-release -o ${{ steps.set-version.outputs.name }}.vsix --githubBranch prerelease | |
- uses: actions/upload-artifact@v2 | |
if: (runner.os == 'Windows') && (github.event_name != 'release') | |
with: | |
name: ${{ steps.set-version.outputs.name }}.vsix | |
path: ${{ steps.set-version.outputs.name }}.vsix | |
beta: | |
if: (github.event_name == 'push') | |
runs-on: windows-latest | |
needs: build | |
steps: | |
- uses: actions/download-artifact@v2 | |
with: | |
name: ${{ needs.build.outputs.name }}.vsix | |
- name: Create Pre-Release | |
id: create_release | |
uses: actions/create-release@v1 | |
if: runner.os == 'Windows' | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
tag_name: v${{ needs.build.outputs.version }} | |
release_name: v${{ needs.build.outputs.version }} | |
prerelease: ${{ github.event_name != 'release' }} | |
body: | | |
Changes in this pre-release | |
${{ needs.build.outputs.changelog }} | |
- name: Upload Pre-Release Asset | |
id: upload-release-asset | |
uses: actions/upload-release-asset@v1 | |
if: runner.os == 'Windows' | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
upload_url: ${{ steps.create_release.outputs.upload_url }} | |
asset_path: ${{ needs.build.outputs.name }}.vsix | |
asset_name: ${{ needs.build.outputs.name }}.vsix | |
asset_content_type: application/zip | |
publish: | |
needs: build | |
if: github.event_name == 'release' && needs.build.outputs.taggedbranch == 'prerelease' | |
runs-on: windows-latest | |
steps: | |
- uses: actions/checkout@v2 | |
with: | |
ref: prerelease | |
token: ${{ secrets.TOKEN }} | |
- name: Use Node.js | |
uses: actions/setup-node@v1 | |
with: | |
node-version: 14.x | |
- name: Prepare pre-release build | |
id: set-version | |
shell: bash | |
run: | | |
VERSION=${{ needs.build.outputs.version }} | |
NEXT_VERSION=`echo $VERSION | awk -F. '/[0-9]+\./{$NF++;print}' OFS=.` | |
tmp=$(mktemp) | |
git config --global user.name 'ProjectBot' | |
git config --global user.email 'bot@users.noreply.github.com' | |
jq --arg version "${NEXT_VERSION}-SNAPSHOT" '.version = $version' package.json > "$tmp" && mv "$tmp" package.json | |
git add package.json | |
git commit -m 'auto bump version after pre-release' | |
jq --arg version "$VERSION" '.version = $version' package.json > "$tmp" && mv "$tmp" package.json | |
npm install | |
jq 'del(.enableProposedApi,.enabledApiProposals)' package.json > "$tmp" && mv "$tmp" package.json | |
git push | |
- name: Build pre-release package | |
run: | | |
npx vsce package --pre-release -o ${{ needs.build.outputs.name }}.vsix --githubBranch prerelease | |
- name: Upload Release Asset | |
id: upload-release-asset | |
uses: actions/upload-release-asset@v1 | |
if: runner.os == 'Windows' | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
upload_url: ${{ github.event.release.upload_url }} | |
asset_path: ${{ needs.build.outputs.name }}.vsix | |
asset_name: ${{ needs.build.outputs.name }}.vsix | |
asset_content_type: application/zip | |
- name: Publish to VSCode Marketplace | |
shell: bash | |
run: | | |
[ -n "${{ secrets.VSCE_TOKEN }}" ] && \ | |
npx vsce publish --pre-release --packagePath ${{ needs.build.outputs.name }}.vsix -p ${{ secrets.VSCE_TOKEN }} || true |