Simplify connection workflow #11
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: CI | |
on: | |
push: | |
branches: | |
- master | |
paths-ignore: | |
- ".vscode/**" | |
- ".github/**" | |
- "*.md" | |
- "**/*.md" | |
pull_request: | |
branches: | |
- master | |
release: | |
types: | |
- released | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.base_ref || github.run_id }} | |
cancel-in-progress: false | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
timeout-minutes: 10 | |
strategy: | |
matrix: | |
include: | |
- platarch: win32-x64 | |
ISC_PLATFORM: winx64 | |
- platarch: linux-x64 | |
ISC_PLATFORM: lnxubuntux64 | |
- platarch: darwin-x64 | |
ISC_PLATFORM: macx64 | |
- platarch: darwin-arm64 | |
ISC_PLATFORM: macos | |
outputs: | |
taggedbranch: ${{ steps.find-branch.outputs.taggedbranch }} | |
steps: | |
- name: Check out repository | |
uses: actions/checkout@v4 | |
- name: Fetch tags | |
run: git fetch --depth=1 origin +refs/tags/*:refs/tags/* | |
- name: Find which branch the release tag points at | |
id: find-branch | |
if: github.event_name == 'release' && matrix.platarch == 'LinuxTODO' | |
run: | | |
git fetch --depth=1 origin +refs/heads/*:refs/heads/* | |
set -x | |
TAGGEDBRANCH=$(git for-each-ref --points-at=${{github.sha}} --format='%(refname:lstrip=2)' refs/heads/) | |
echo "taggedbranch=$TAGGEDBRANCH" >> $GITHUB_OUTPUT | |
- name: Set package name and version | |
id: set-version | |
run: | | |
set -x | |
VERSION=$(jq -r '.version' package.json | cut -d- -f1) | |
[ $GITHUB_EVENT_NAME == 'release' ] && VERSION=${{ github.event.release.tag_name }} && VERSION=${VERSION/v/} | |
CHANGELOG=$(cat CHANGELOG.md | sed -n "/## \[${VERSION}\]/,/## /p" | sed '/^$/d;1d;$d') | |
CHANGELOG="${CHANGELOG//$'\n'/'%0A'}" | |
echo "changelog=$CHANGELOG" >> $GITHUB_OUTPUT | |
git tag -l | cat | |
[ $GITHUB_EVENT_NAME == 'push' ] && VERSION+=-beta && VERSION+=.$(($(git tag -l "v$VERSION.*" | sort -nt. -k4 2>/dev/null | tail -1 | cut -d. -f4)+1)) | |
[ $GITHUB_EVENT_NAME == 'pull_request' ] && VERSION+=-dev.${{ github.event.pull_request.number }} | |
echo "version=$VERSION" >> $GITHUB_OUTPUT | |
NAME=$(jq -r '.name' package.json)-$VERSION-${{ matrix.platarch }} | |
echo "name=$NAME" >> $GITHUB_OUTPUT | |
tmp=$(mktemp) | |
jq --arg version "$VERSION" '.version = $version' package.json > "$tmp" && mv "$tmp" package.json | |
mkdir dist | |
echo $VERSION > meta.version | |
echo $NAME > meta.name | |
- name: Use Node.js | |
uses: actions/setup-node@v4 | |
with: | |
node-version: 18 | |
- run: npm install | |
- name: lint | |
if: matrix.platarch == 'Linux-IGNORE' | |
run: npm run lint | |
- run: npm run compile | |
- name: npm test | |
if: matrix.platarch == 'Linux-IGNORE' | |
uses: coactions/setup-xvfb@v1 | |
with: | |
run: npm run test | |
- name: Build package | |
run: | | |
node -e "require('fs').cpSync('./intersystems-iris-native/bin/${{ matrix.ISC_PLATFORM }}/', './dist/', { recursive: true, filter: (f) => !f.endsWith('irisnative.node') })" | |
npx vsce package --target ${{ matrix.platarch }} -o ${{ steps.set-version.outputs.name }}.vsix | |
- name: Upload package | |
uses: actions/upload-artifact@v4 | |
if: (github.event_name != 'release') | |
with: | |
name: ${{ steps.set-version.outputs.name }}.vsix | |
path: ${{ steps.set-version.outputs.name }}.vsix | |
- name: Upload metadata | |
uses: actions/upload-artifact@v4 | |
if: matrix.platarch == 'linux-x64' | |
with: | |
name: meta | |
path: meta.version | |
beta: | |
runs-on: ubuntu-latest | |
needs: build | |
if: success() && github.event_name == 'push' | |
steps: | |
- name: Download metadata | |
uses: actions/download-artifact@v4 | |
with: | |
name: meta | |
path: . | |
- name: Set version output | |
id: set-version | |
run: | | |
set -x | |
echo "version=`cat meta.version`" >> $GITHUB_OUTPUT | |
- name: Download packages | |
uses: actions/download-artifact@v4 | |
with: | |
pattern: '**/*.vsix' | |
- name: Create Release | |
id: create-release | |
uses: softprops/action-gh-release@v2 | |
with: | |
tag_name: v${{ steps.set-version.outputs.version }} | |
prerelease: ${{ github.event_name != 'release' }} | |
files: '**/*.vsix' | |
token: ${{ secrets.GITHUB_TOKEN }} | |
publish: | |
runs-on: ubuntu-latest | |
needs: build | |
if: success() && github.event_name == 'release' | |
steps: | |
- name: Use Node.js | |
uses: actions/setup-node@v4 | |
with: | |
node-version: 18 | |
- run: npm install -g @vscode/vsce | |
- name: Download packages | |
uses: actions/download-artifact@v4 | |
- name: Attach packages to release | |
uses: softprops/action-gh-release@v2 | |
with: | |
tag_name: ${{ github.event.release.tag_name }} | |
files: '**/*.vsix' | |
body: See CHANGELOG for details | |
token: ${{ secrets.GITHUB_TOKEN }} | |
- name: Publish to VS Code Marketplace | |
env: | |
VSCE_PAT: ${{ secrets.VSCE_TOKEN }} | |
if: env.VSCE_PAT != null | |
run: vsce publish --packagePath $(find . -iname "*.vsix" -type f) | |
- name: Publish to Open VSX Registry | |
env: | |
OVSX_PAT: ${{ secrets.OVSX_TOKEN }} | |
if: env.OVSX_PAT != null | |
timeout-minutes: 5 | |
run: find . -iname "*.vsix" -type f -exec npx ovsx publish {} \; | |
bump_version: | |
runs-on: ubuntu-latest | |
needs: [build, publish] | |
if: github.event_name == 'release' | |
steps: | |
- name: Check out repository | |
uses: actions/checkout@v4 | |
with: | |
ref: master | |
- name: Download metadata | |
uses: actions/download-artifact@v4 | |
with: | |
name: meta | |
path: . | |
- name: Use Node.js | |
uses: actions/setup-node@v4 | |
with: | |
node-version: 18 | |
- name: Create commit | |
run: | | |
VERSION=`cat meta.version` | |
NEXT_VERSION=`cat meta.version | awk -F. '/[0-9]+\./{$NF++;print}' OFS=.` | |
tmp=$(mktemp) | |
git config --global user.name 'ProjectBot' | |
git config --global user.email '[email protected]' | |
jq --arg version "${NEXT_VERSION}-SNAPSHOT" '.version = $version' package.json > "$tmp" && mv "$tmp" package.json | |
git add package.json | |
git commit -m 'auto bump version with release [skip ci]' | |
git push |