Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[CI] Configure build/publishing of VSCode extension #17

Merged
merged 1 commit into from
May 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,65 +1,25 @@
# Create a release for a given Git ref.
# Build binaries for a given Git ref.
# Based on:
# - https://github.com/BurntSushi/ripgrep/blob/d922b7ac114c24d6800ae5f79d2967481f380c83/.github/workflows/release.yml
# - https://github.com/dafny-lang/dafny/blob/beab582113744ea72e2727d934f5a03d42c4ba17/.github/workflows/publish-release-reusable.yml
name: Create Release
name: Build Binaries

on:
workflow_call:
inputs:
git_ref:
required: true
type: string
version:
required: true
type: string
is_prerelease:
required: true
type: boolean
jobs:
# The create-release job runs purely to initialize the GitHub release itself,
# and names the release after the provided Git ref (e.g. tag). It's separate
# from building the release so that we only create the release once.
create-release:
name: create-release
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
ref: ${{ inputs.git_ref }}

- name: Get the release version from the tag
if: env.VERSION == ''
run: echo "VERSION=${{ inputs.git_ref }}" >> $GITHUB_ENV

- name: Show the version
run: |
echo "version is: $VERSION"

- name: Check that tag version and Cargo.toml version are the same
if: ${{ !inputs.is_prerelease }}
shell: bash
# Remove leading v from semantic versioning tag v<major>.<minor>.<patch>
run: |
VERSION_WITHOUT_V=${VERSION#v}
if ! grep -q "version = \"${VERSION_WITHOUT_V}\"" Cargo.toml; then
echo "version ${VERSION_WITHOUT_V} does not match Cargo.toml" >&2
exit 1
fi

- name: Create Release
uses: softprops/action-gh-release@v2
with:
name: ${{ env.VERSION }}
tag_name: ${{ inputs.git_ref }}
draft: ${{ !inputs.is_prerelease }}
prerelease: ${{ inputs.is_prerelease }}
generate_release_notes: ${{ inputs.is_prerelease }}

outputs:
version: ${{ env.VERSION }}

jobs:
build-release:
name: build-release
needs: ['create-release']
runs-on: ${{ matrix.os }}
env:
# For some builds, we use cross to test on 32-bit and big-endian
Expand Down Expand Up @@ -160,7 +120,7 @@ jobs:
- name: Determine archive name
shell: bash
run: |
version="${{ needs.create-release.outputs.version }}"
version="${{ inputs.version }}"
echo "ARCHIVE=caesar-$version-${{ matrix.target }}" >> $GITHUB_ENV

- name: Creating directory for archive
Expand Down
55 changes: 55 additions & 0 deletions .github/workflows/build-vsix-gh_release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
# Build a VSIX bundle for the VScode extension and add it to GitHub release
name: Build VSIX

on:
workflow_call:
inputs:
git_ref:
required: true
type: string
version:
required: true
type: string
is_prerelease:
required: true
type: boolean

env:
EXTENSION_DIRECTORY: ./vscode-ext

jobs:
build-vsix:
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
ref: ${{ inputs.git_ref }}

- name: Install Node.js
uses: actions/setup-node@v4

- name: Install NPM dependencies
working-directory: ${{ env.EXTENSION_DIRECTORY }}
run: npm install

- name: Set npm flags (for pre-release)
if: ${{ inputs.is_prerelease }}
shell: bash
run: |
echo "NPM_EXTRA_FLAGS=--pre-release" >> $GITHUB_ENV

- name: Package the extension
working-directory: ${{ env.EXTENSION_DIRECTORY }}
run: npm run package -- --out caesar-${{ inputs.version }}.vsix $NPM_EXTRA_FLAGS

- name: Upload Release Files
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ inputs.git_ref }}
# Also need to specify 'draft' again, so that the action finds the correct existing (draft) release
draft: ${{ !inputs.is_prerelease }}
files: |
${{env.EXTENSION_DIRECTORY}}/caesar-${{ inputs.version }}.vsix

51 changes: 51 additions & 0 deletions .github/workflows/build-vsix-marketplaces.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
# Build and publish VSIX bundle of the VScode extension to marketplaces
name: Publish VSIX to Marketplaces

on:
workflow_call:
inputs:
git_ref:
required: true
type: string
version:
required: true
type: string

env:
EXTENSION_DIRECTORY: ./vscode-ext

jobs:
publish-vsix:
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
ref: ${{ inputs.git_ref }}

- name: Install Node.js
uses: actions/setup-node@v4

- name: Install NPM dependencies
working-directory: ${{ env.EXTENSION_DIRECTORY }}
run: npm install

- name: Package the extension
working-directory: ${{ env.EXTENSION_DIRECTORY }}
run: npm run package -- --out caesar-${{ inputs.version }}.vsix

- name: Publish the extension (Visual Studio Marketplace)
uses: HaaLeo/publish-vscode-extension@v1
with:
registryUrl: https://marketplace.visualstudio.com
pat: ${{ secrets.VSCE_PAT }}
extensionFile: ${{env.EXTENSION_DIRECTORY}}/caesar-${{ inputs.version }}.vsix

- name: Publish the extension (Open VSX Registry)
uses: HaaLeo/publish-vscode-extension@v1
with:
registryUrl: https://open-vsx.org
pat: ${{ secrets.OPEN_VSX_PAT }}
extensionFile: ${{env.EXTENSION_DIRECTORY}}/caesar-${{ inputs.version }}.vsix

54 changes: 54 additions & 0 deletions .github/workflows/create_nightly_release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
name: Nightly release (on change to main branch)
on:
push:
branches:
- main

env:
# Name of the tag to mark current nightly build
NIGHTLY_TAG: nightly

jobs:
create-nightly-tag:
name: create-nightly-tag
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Ensure tag exists
run: |
git tag ${{ env.NIGHTLY_TAG }} -f
git push origin ${{ env.NIGHTLY_TAG }} -f
outputs:
tag: ${{ env.NIGHTLY_TAG }}

prepare-release:
needs: create-nightly-tag
uses: ./.github/workflows/setup_gh_release.yml
with:
git_ref: ${{ needs.create-nightly-tag.outputs.tag }}
is_prerelease: true

build-binaries:
needs: [create-nightly-tag, prepare-release]
uses: ./.github/workflows/build-binaries-gh_release.yml
with:
git_ref: ${{ needs.create-nightly-tag.outputs.tag }}
version: ${{ needs.prepare-release.outputs.version }}
is_prerelease: true

build-vsix:
needs: [create-nightly-tag, prepare-release]
uses: ./.github/workflows/build-vsix-gh_release.yml
with:
git_ref: ${{ needs.create-nightly-tag.outputs.tag }}
version: ${{ needs.prepare-release.outputs.version }}
is_prerelease: true

publish-docker-image:
needs: [create-nightly-tag, prepare-release]
uses: ./.github/workflows/build-docker-registry.yml
with:
git_ref: ${{ needs.create-nightly-tag.outputs.tag }}
image_tags: |
type=raw,value=${{ needs.create-nightly-tag.outputs.tag }}
30 changes: 30 additions & 0 deletions .github/workflows/create_tagged_release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: Tagged version release

# Only do the release on semantic versioning v<major>.<minor>.<patch> tags.
on:
push:
tags:
- "v[0-9]+.[0-9]+.[0-9]+"

jobs:
prepare-release:
uses: ./.github/workflows/setup_gh_release.yml
with:
git_ref: ${{ github.ref_name }}
is_prerelease: false

build-binaries:
needs: prepare-release
uses: ./.github/workflows/build-binaries-gh_release.yml
with:
git_ref: ${{ github.ref_name }}
version: ${{ needs.prepare-release.outputs.version }}
is_prerelease: false

build-vsix:
needs: prepare-release
uses: ./.github/workflows/build-vsix-gh_release.yml
with:
git_ref: ${{ github.ref_name }}
version: ${{ needs.prepare-release.outputs.version }}
is_prerelease: false
36 changes: 0 additions & 36 deletions .github/workflows/nightly_release.yml

This file was deleted.

21 changes: 21 additions & 0 deletions .github/workflows/on_tagged_release_publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: Publish artifacts to external repositories when tagged version is released

on:
release:
# Only do the release on proper releases (with semantic versioning tags).
types: [released]

jobs:
publish-docker-image:
uses: ./.github/workflows/build-docker-registry.yml
with:
git_ref: ${{ github.ref_name }}
# Creation of semver tag also causes creation of 'latest' tag
image_tags: |
type=semver,pattern={{version}}

publish-vsix:
uses: ./.github/workflows/build-vsix-marketplaces.yml
with:
git_ref: ${{ github.ref_name }}
version: ${{ github.ref_name }}
Loading
Loading