Merge pull request #299 from vivaxy/prepare-release #28
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: release | |
on: | |
workflow_dispatch: | |
push: | |
branches: | |
- master | |
paths: | |
- CHANGELOG.md | |
jobs: | |
release: | |
name: release | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/[email protected] | |
with: | |
fetch-depth: 0 | |
- name: Setup nodejs | |
uses: actions/[email protected] | |
with: | |
node-version: 14 | |
- name: Setup package | |
run: yarn install | |
- name: Bump version | |
if: ${{ github.event_name == 'workflow_dispatch' }} | |
run: | | |
yarn standard-version --skip.commit --skip.tag | |
sed 's/^### \[/## [/' -i CHANGELOG.md | |
yarn prettier --write CHANGELOG.md --prose-wrap never --ignore-path ./gitignore | |
- name: Get version from package.json | |
uses: actions/[email protected] | |
id: version | |
with: | |
result-encoding: string | |
script: | | |
const { GITHUB_WORKSPACE } = process.env; | |
const version = require(`${GITHUB_WORKSPACE}/package.json`).version; | |
core.setOutput('repo', context.repo.repo); | |
core.setOutput('version', version); | |
- name: Setup git information | |
run: | | |
git config --global user.name "github-actions[bot]" | |
git config --global user.email "github-actions[bot]@users.noreply.github.com" | |
- name: Create commit | |
if: ${{ github.event_name == 'workflow_dispatch' }} | |
run: | | |
git add . | |
git commit -m "chore(release): :bookmark: release v${{steps.version.outputs.version}}" | |
- name: Create tag | |
run: | | |
git tag -a v${{steps.version.outputs.version}} -m "chore(release): :bookmark: release v${{steps.version.outputs.version}}" | |
- name: Build release asset | |
run: yarn build | |
- name: Publish package to visual studio marketplace | |
run: yarn deploy -p ${{secrets.VSCE_PAT}} | |
- name: Publish package to open VSX registry | |
env: | |
FILENAME: ${{steps.version.outputs.repo}}-${{steps.version.outputs.version}}.vsix | |
run: yarn ovsx publish ${{env.FILENAME}} -p ${{secrets.OPEN_VSX_TOKEN}} | |
- name: Push release commit | |
env: | |
REMOTE_URL: https://x-access-token:${{secrets.GITHUB_TOKEN}}@github.com/${{github.repository}}.git | |
run: | | |
git push --follow-tags "${{env.REMOTE_URL}}" | |
- name: Get changelog context | |
id: changelog_reader | |
uses: mindsers/[email protected] | |
with: | |
version: ${{steps.version.outputs.version}} | |
path: ./CHANGELOG.md | |
- name: Create release | |
id: create_release | |
uses: actions/[email protected] | |
env: | |
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}} | |
with: | |
tag_name: v${{steps.version.outputs.version}} | |
release_name: Release v${{steps.version.outputs.version}} | |
body: ${{ steps.changelog_reader.outputs.changes }} | |
prerelease: | |
${{ steps.changelog_reader.outputs.status == 'prereleased' }} | |
draft: ${{ steps.changelog_reader.outputs.status == 'unreleased' }} | |
- name: Upload release asset | |
uses: actions/[email protected] | |
env: | |
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}} | |
with: | |
upload_url: ${{steps.create_release.outputs.upload_url}} | |
asset_path: ./${{steps.version.outputs.repo}}-${{steps.version.outputs.version}}.vsix | |
asset_name: ${{steps.version.outputs.repo}}-${{steps.version.outputs.version}}.vsix | |
asset_content_type: application/octet-stream |