Files
vscode-codeql/.github/workflows/release.yml
Aditya Sharad d9a1dce7fa
Some checks failed
Build Extension / Build (ubuntu-latest) (push) Has been cancelled
Build Extension / Build (windows-latest) (push) Has been cancelled
Build Extension / Test (ubuntu-latest) (push) Has been cancelled
Build Extension / Test (windows-latest) (push) Has been cancelled
Release / Release (push) Has been cancelled
CodeQL for VS Code: Initial commit.
2019-11-13 12:23:53 -08:00

90 lines
3.6 KiB
YAML

# Build and release a new version of the extension.
# Based on example workflow at https://github.com/actions/upload-release-asset
# licensed under https://github.com/actions/upload-release-asset/blob/master/LICENSE.
# Reference for passing data between steps:
# https://jasonet.co/posts/new-features-of-github-actions/#passing-data-to-future-steps
name: Release
on:
push:
# Path filters are not evaluated for pushes to tags.
# (source: https://help.github.com/en/github/automating-your-workflow-with-github-actions/workflow-syntax-for-github-actions#onpushpull_requestpaths)
# So this workflow is triggered in the following events:
# - Release event: a SemVer tag, e.g. v1.0.0 or v1.0.0-alpha, is pushed
tags:
- 'v[0-9]+.[0-9]+.[0-9]+*'
# OR
# - Test event: this file is modified on a branch in the main repo containing `/actions/` in the name.
branches:
- '**/actions/**'
paths:
- '**/workflows/release.yml'
jobs:
build:
name: Release
runs-on: ubuntu-latest
# TODO Share steps with the main workflow.
steps:
- name: Checkout
uses: actions/checkout@master
- name: Build
run: |
cd build
npm install
# Release build instead of dev build.
npm run build-release
shell: bash
- name: Prepare artifacts
id: prepare-artifacts
run: |
mkdir artifacts
cp dist/*.vsix artifacts
# Record the VSIX path as an output of this step.
# This will be used later when uploading a release asset.
VSIX_PATH="$(ls dist/*.vsix)"
echo "::set-output name=vsix_path::$VSIX_PATH"
# Transform the GitHub ref so it can be used in a filename.
# This is mainly needed for testing branches that modify this workflow.
REF_NAME="$(echo ${{ github.ref }} | sed -e 's:/:-:g')"
echo "::set-output name=ref_name::$REF_NAME"
# Uploading artifacts is not necessary to create a release.
# This is just in case the release itself fails and we want to access the built artifacts from Actions.
# TODO Remove if not useful.
- name: Upload artifacts
uses: actions/upload-artifact@master
with:
name: vscode-codeql-extension
path: artifacts
# TODO Run tests, or check that a test run on the same branch succeeded.
- name: Create release
id: create-release
uses: actions/create-release@v1.0.0
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.ref }}
release_name: Release ${{ github.ref }}
# This gives us a chance to manually review the created release before publishing it,
# as well as to test the release workflow by pushing temporary tags.
# Once we have set all required release metadata in this step, we can set this to `false`.
draft: true
prerelease: false
- name: Upload release asset
uses: actions/upload-release-asset@v1.0.1
if: success()
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
# Get the `upload_url` from the `create-release` step above.
upload_url: ${{ steps.create-release.outputs.upload_url }}
# Get the `vsix_path` and `ref_name` from the `prepare-artifacts` step above.
asset_path: ${{ steps.prepare-artifacts.outputs.vsix_path }}
asset_name: ${{ format('vscode-codeql-{0}.vsix', steps.prepare-artifacts.outputs.ref_name) }}
asset_content_type: application/zip