Create dependabot.yml #14
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: Package Extension | |
on: | |
push: | |
branches: | |
- main | |
jobs: | |
once: | |
permissions: | |
contents: write # for creating release | |
name: Create vsix | |
runs-on: ubuntu-latest | |
outputs: | |
upload_url: ${{ steps.create_release.outputs.upload_url }} | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v2 | |
- name: Install Node.js | |
uses: actions/setup-node@v2 | |
with: | |
node-version: "20" | |
- name: Install npm dependencies | |
run: npm install | |
- name: Get package version | |
id: get_package_version_ubuntu | |
run: echo "version=$(node -p "require('./package.json').version")" >> $GITHUB_OUTPUT | |
- name: Get package name | |
id: get_package_name_ubuntu | |
run: echo "name=$(node -p "require('./package.json').name")" >> $GITHUB_OUTPUT | |
- name: Build extension | |
run: npm run prepackage | |
- name: Install vsce globally | |
run: npm install -g @vscode/vsce | |
- name: Package extension | |
run: vsce package --no-yarn --allow-star-activation -o . | |
- name: Fetch latest commit hash | |
id: get_commit_hash_ubuntu | |
run: echo "hash=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT | |
- name: Rename and move VSIX file | |
id: rename_vsix_ubuntu | |
run: | | |
old_name="${{ steps.get_package_name_ubuntu.outputs.name }}-${{ steps.get_package_version_ubuntu.outputs.version }}.vsix" | |
new_name="${old_name%.*}-${{ steps.get_commit_hash_ubuntu.outputs.hash }}.vsix" | |
mkdir -p releases | |
mv "$old_name" "releases/$new_name" | |
echo "new_name=$new_name" >> $GITHUB_OUTPUT | |
- name: Create GitHub Release | |
id: create_release | |
uses: actions/create-release@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
tag_name: ${{ steps.get_package_version_ubuntu.outputs.version }}-${{ steps.get_commit_hash_ubuntu.outputs.hash }} | |
release_name: ${{ steps.get_package_version_ubuntu.outputs.version }}-${{ steps.get_commit_hash_ubuntu.outputs.hash }} | |
body: | | |
Release created automatically from workflow. | |
draft: true | |
prerelease: true | |
- name: Upload VSIX file as release asset | |
uses: actions/upload-release-asset@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
upload_url: ${{ steps.create_release.outputs.upload_url }} | |
asset_path: releases/${{ steps.rename_vsix_ubuntu.outputs.new_name }} | |
asset_name: ${{ steps.get_package_name_ubuntu.outputs.name }}-${{ steps.get_package_version_ubuntu.outputs.version }}-${{ steps.get_commit_hash_ubuntu.outputs.hash }}.vsix | |
asset_content_type: application/zip | |
- name: Display success message | |
run: echo "Extension packaging complete and release created with asset uploaded." |