blob: 342a43fdbce1498b35bcd42ccf7df66cf77138fd [file] [log] [blame]
name: Release (golang.go)
# The new release workflow is triggered when a new tag on the release
# branch is pushed.
#
# Note: our canonical repository is in go.googlesource.com/vscode-go and tagging
# will be done in the canonical repository, and mirrored to the github repository.
# A typical workflow is:
#
# 1. A human operator creates a CL to merge the main dev branch to the 'release' branch.
# CI (GCB builder) will test the CL.
# 2. The CL is reviewed and merged. This triggers the "Long test workflow" (test-long.yml).
# 3. The human operator verifies the "Long test workflow" is green.
# Otherwise, fix (fix, cherry-pick, review, commit) on the 'release' branch.
# 4. When the 'release' branch reaches to the state ready for the release,
# the human operator will tag the commig from the canonical repository.
# (https://go-review.googlesource.com/admin/repos/vscode-go,tags)
# Stable versions should be in the format of 'vX.X.X' (e.g. v0.15.0)
# Release candidates should be in the format of 'vX.X.X-rc.X' (e.g. v0.15.0-rc.1)
# 5. The gopherbot will mirror the tag to the GitHub repo, and that push will trigger
# the 'Release (golang.go)' workflow specified in this file.
# - For stable version release (vX.X.X), check if the package.json has the matching version.
# - Packaging using 'vsce package'
# - Create a release in GitHub
# - Upload the vsix file as an asset of the release
# - For stable version release (vX.X.X), upload to the vscode market place
on:
push:
tags:
- v*
jobs:
release:
name: create release
runs-on: ubuntu-latest
if: github.repository == 'golang/vscode-go'
steps:
- name: Clone repository
uses: actions/checkout@v3
- name: Setup Node
uses: actions/setup-node@v3
with:
node-version: '18'
cache: 'npm'
- name: get release version
id: release_version
run: |
TAGGED_VERSION="${GITHUB_REF/refs\/tags\/v/}"
if [[ ! "${TAGGED_VERSION}" =~ ^[0-9]+\.[0-9]+\.[0-9]+.*$ ]]; then
echo "Invalid version tag '${TAGGED_VERSION}'"
exit 1
fi
echo "EXT_VERSION=${TAGGED_VERSION}" >> $GITHUB_ENV
WRITTEN_VERSION="$(cat package.json | jq '.version' -r)"
if [[ "${TAGGED_VERSION}" == *"-"* ]]; then
if [[ ! "${TAGGED_VERSION}" == "${WRITTEN_VERSION}"-rc.* ]]; then
echo "Prerelease Tag and Version in package.json are not compatible: '${TAGGED_VERSION}' vs '${WRITTEN_VERSION}'"
exit 1
fi
echo "EXT_ISPREVIEW=1" >> $GITHUB_ENV
else
if [[ "${TAGGED_VERSION}" != "${WRITTEN_VERSION}" ]]; then
echo "Release Tag and Version in package.json do not match: '${TAGGED_VERSION}' vs '${WRITTEN_VERSION}'"
exit 1
fi
echo "EXT_ISPREVIEW=0" >> $GITHUB_ENV
fi
- name: stamp version
run: |
cat package.json | jq --arg VER "${{ env.EXT_VERSION }}" '.version=$VER' > /tmp/package.json
cp /tmp/package.json ./package.json
npm ci
npm run vscode:prepublish
- name: package
uses: lannonbr/vsce-action@0f3391ee0477b08fae949eb0a875e91e6d20b075
with:
args: "package"
- name: create release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.ref }}
release_name: Release ${{ env.EXT_VERSION }}
draft: false
prerelease: ${{env.EXT_ISPREVIEW == 1}}
- name: upload 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: ./go-${{ env.EXT_VERSION }}.vsix
asset_name: go-${{ env.EXT_VERSION }}.vsix
asset_content_type: application/zip
- name: publish
if: env.EXT_ISPREVIEW != 1 && github.repository == 'golang/vscode-go'
uses: lannonbr/vsce-action@0f3391ee0477b08fae949eb0a875e91e6d20b075
with:
args: "publish -p $VSCE_TOKEN"
env:
VSCE_TOKEN: ${{ secrets.VSCE_TOKEN }}
# TODO: check if the commit is in green state. (test-long.yml results)