feat: Upgrade actions/upload-artifact and actions/download-artifact t… #2
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 and Release | |
on: | |
push: | |
branches: [ main ] | |
pull_request: | |
branches: [ main ] | |
release: | |
types: [created] | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Setup Node.js | |
uses: actions/setup-node@v3 | |
with: | |
node-version: '20.x' | |
- name: Install dependencies | |
run: | | |
cd partnerId | |
npm install | |
- name: Install TFX-CLI | |
run: npm install -g tfx-cli | |
- name: Build extension | |
run: | | |
# Create VSIX package | |
tfx extension create --manifest-globs vss-extension.json --output-path ./dist | |
- name: Upload artifact | |
uses: actions/upload-artifact@v4 | |
with: | |
name: vsix-package | |
path: "dist/*.vsix" | |
publish: | |
needs: build | |
if: github.event_name == 'release' | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Update version numbers | |
run: | | |
# Extract version from release tag (without v prefix) | |
VERSION=${GITHUB_REF#refs/tags/} | |
# Split version into parts | |
IFS='.' read -r MAJOR MINOR PATCH <<< "$VERSION" | |
# Update task.json | |
jq --arg major "$MAJOR" --arg minor "$MINOR" --arg patch "$PATCH" \ | |
'.version.Major = ($major|tonumber) | .version.Minor = ($minor|tonumber) | .version.Patch = ($patch|tonumber)' \ | |
partnerId/task.json > temp.json && mv temp.json partnerId/task.json | |
# Update vss-extension.json | |
jq --arg version "$VERSION" \ | |
'.version = $version' \ | |
vss-extension.json > temp.json && mv temp.json vss-extension.json | |
- name: Download artifact | |
uses: actions/download-artifact@v4 | |
with: | |
name: vsix-package | |
path: dist | |
- name: Publish to Marketplace | |
if: github.event_name == 'release' | |
run: | | |
npx tfx-cli extension publish --vsix dist/*.vsix --token ${{ secrets.AZURE_DEVOPS_PAT }} | |
- name: Upload to GitHub Release | |
uses: actions/upload-release-asset@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
upload_url: ${{ github.event.release.upload_url }} | |
asset_path: ./dist/*.vsix | |
asset_name: partner-id-task-${{ github.event.release.tag_name }}.vsix | |
asset_content_type: application/octet-stream |