Build & Publish #51
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 & Publish | |
on: [workflow_dispatch] | |
permissions: | |
contents: read | |
jobs: | |
JobBuild: | |
name: release | |
runs-on: ubuntu-latest | |
# Expose step outputs as job outputs | |
outputs: | |
currentversion: ${{ steps.package_version.outputs.current-version }} | |
changelog_reader_changes: ${{ steps.changelog_reader.outputs.changes }} | |
permissions: | |
actions: read | |
contents: read | |
deployments: read | |
packages: none | |
steps: | |
- name: Harden Runner | |
uses: step-security/harden-runner@17d0e2bd7d51742c71671bd19fa12bdc9d40a3d6 # v2.8.1 | |
with: | |
egress-policy: audit | |
- name: Checkout | |
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 | |
- name: Use Node.js | |
uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4.0.2 | |
with: | |
node-version: 20 | |
# Run install dependencies | |
- name: Install dependencies | |
run: npm run install:all | |
# Ensure project builds successfully before creating release | |
- name: Build | |
run: npm run webpack | |
- name: Get current package version | |
id: package_version | |
uses: martinbeentjes/npm-get-version-action@3cf273023a0dda27efcd3164bdfb51908dd46a5b # v1.3.1 | |
- name: Check version is mentioned in Changelog | |
id: changelog_reader | |
uses: mindsers/changelog-reader-action@32aa5b4c155d76c94e4ec883a223c947b2f02656 # v2.2.3 | |
with: | |
validation_depth: 10 | |
version: ${{ steps.package_version.outputs.current-version }} | |
path: 'CHANGELOG.md' | |
JobsPublish: | |
name: publish | |
runs-on: ubuntu-latest | |
needs: JobBuild | |
permissions: | |
actions: read | |
contents: write | |
deployments: read | |
packages: none | |
steps: | |
- name: Harden Runner | |
uses: step-security/harden-runner@17d0e2bd7d51742c71671bd19fa12bdc9d40a3d6 # v2.8.1 | |
with: | |
egress-policy: audit | |
# Checkout the code again for release | |
- name: Checkout | |
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 | |
- name: Use Node.js | |
uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4.0.2 | |
with: | |
node-version: 20 | |
# Run install dependencies | |
- name: Install dependencies | |
run: npm run install:all | |
- name: Create a Release | |
id: create_release | |
uses: actions/create-release@0cb9c9b65d5d1901c1f53e5e66eaf4afd303e70e # v1.1.4 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
tag_name : ${{ needs.JobBuild.outputs.currentversion }} | |
release_name: ${{ needs.JobBuild.outputs.currentversion}} | |
body: Publish ${{ needs.JobBuild.outputs.changelog_reader_changes }} | |
- name: Create vsix and publish to marketplace | |
id: create_vsix | |
uses: HaaLeo/publish-vscode-extension@28e2d3f5817fccf23c1f219eb0cecc903132d1a2 # v1.6.2 | |
with: | |
pat: ${{ secrets.VS_MARKETPLACE_TOKEN }} | |
registryUrl: https://marketplace.visualstudio.com | |
- name: Attach vsix to release | |
uses: actions/upload-release-asset@e8f9f06c4b078e705bd2ea027f0926603fc9b4d5 # v1.0.2 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
upload_url: ${{ steps.create_release.outputs.upload_url }} | |
asset_path: ${{ steps.create_vsix.outputs.vsixPath}} | |
asset_name: ${{ steps.create_vsix.outputs.vsixPath}} | |
asset_content_type: application/vsix | |