0.0.3-test.3 #4
Workflow file for this run
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
# This workflow will run tests using node and then publish a package to GitHub Packages when a release is created | |
# For more information see: https://docs.github.com/en/actions/publishing-packages/publishing-nodejs-packages | |
name: Publish Cardano Devkit VSCode Extension | |
on: | |
pull_request: | |
types: | |
- closed | |
branches: | |
- main | |
release: | |
types: | |
- created | |
jobs: | |
build: | |
strategy: | |
matrix: | |
os: [macos-latest, ubuntu-latest, windows-latest] | |
runs-on: ${{ matrix.os }} | |
defaults: | |
run: | |
working-directory: vscode-extension | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Install Node.js | |
uses: actions/setup-node@v4 | |
with: | |
node-version: 18.x | |
- run: yarn install | |
- run: xvfb-run -a yarn test | |
if: runner.os == 'Linux' | |
- run: yarn test | |
if: runner.os != 'Linux' | |
check-version: | |
runs-on: ubuntu-latest | |
outputs: | |
version-updated: ${{ steps.compare-versions.outputs.version-updated }} | |
steps: | |
- name: Set default output | |
id: set-output | |
run: echo "version-updated=false" >> $GITHUB_OUTPUT | |
- name: Checkout main branch at commit before merge | |
if: github.event.pull_request.merged == true | |
uses: actions/checkout@v4 | |
with: | |
ref: ${{ github.event.pull_request.base.sha }} | |
- name: Get package version from main branch before merge | |
if: github.event.pull_request.merged == true | |
id: pre-merge-version | |
run: | | |
PRE_MERGE_VERSION=$(node -p "require('./vscode-extension/package.json').version") | |
- name: Checkout main branch at commit after merge | |
if: github.event.pull_request.merged == true | |
uses: actions/checkout@v4 | |
with: | |
ref: "main" | |
- name: Get package version from main branch after merge | |
if: github.event.pull_request.merged == true | |
id: post-merge-version | |
run: | | |
POST_MERGE_VERSION=$(node -p "require('./vscode-extension/package.json').version") | |
- name: Compare versions | |
if: github.event.pull_request.merged == true | |
id: compare-versions | |
run: | | |
if [[ "${{ steps.pre-merge-version.outputs.pre_merge_version }}" != "${{ steps.post-merge-version.outputs.post_merge_version }}" ]]; then | |
echo "version-updated=true" >> "$GITHUB_OUTPUT" | |
else | |
echo "version-updated=false" >> "$GITHUB_OUTPUT" | |
fi | |
publish: | |
needs: [build, check-version] | |
if: needs.check-version.outputs.version-updated == 'true' || github.event_name == 'release' | |
strategy: | |
matrix: | |
os: [macos-latest, ubuntu-latest, windows-latest] | |
runs-on: ${{ matrix.os }} | |
defaults: | |
run: | |
working-directory: vscode-extension | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Install Node.js | |
uses: actions/setup-node@v4 | |
with: | |
node-version: 18.x | |
- run: yarn install | |
- name: Publish | |
if: success() && startsWith(github.ref, 'refs/tags/') && matrix.os == 'ubuntu-latest' | |
run: yarn deploy | |
env: | |
VSCE_PAT: ${{ secrets.VSCE_PAT }} |