Publish #157
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: Publish | |
on: | |
workflow_dispatch: | |
inputs: | |
releaseType: | |
description: "Release Type" | |
required: true | |
type: choice | |
default: "patch" | |
options: | |
- patch | |
- minor | |
- major | |
releaseChannel: | |
description: "Release Channel" | |
required: true | |
type: choice | |
default: stable | |
options: | |
- stable | |
- edge | |
publishMarketplace: | |
description: "Publish on Visual Studio Marketplace?" | |
required: true | |
type: choice | |
default: "yes" | |
options: | |
- "yes" | |
- "no" | |
publishOpenVSX: | |
description: "Publish on Open VSX Registry?" | |
required: true | |
type: choice | |
default: "yes" | |
options: | |
- "yes" | |
- "no" | |
jobs: | |
release: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Check for correct branch (Edge) | |
if: github.event.inputs.releaseChannel == 'edge' | |
run: | | |
if [ "$GITHUB_REF_NAME" = "edge" ]; then | |
echo "Correct branch was used, proceeding with edge release" | |
else | |
echo "The 'edge' release must come from a branch called 'edge'" | |
echo "(it was: '${GITHUB_REF_NAME}')" | |
exit 1 | |
fi; | |
- name: Check for correct branch (Stable) | |
if: github.event.inputs.releaseChannel == 'stable' | |
run: | | |
if [ "$GITHUB_REF_NAME" = "main" ]; then | |
echo "Correct branch was used, proceeding with stable release" | |
else | |
echo "The 'stable' release must come from a branch called 'main'" | |
echo "(it was: '${GITHUB_REF_NAME}')" | |
exit 1 | |
fi; | |
- name: Clone Repository | |
uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # pin@v3 | |
with: | |
fetch-depth: 0 | |
- name: Setup Flux CLI | |
uses: fluxcd/flux2/action@1730f3c46bddf0a29787d8d4fa5ace283f298e49 # pin@main | |
with: | |
token: ${{ secrets.GITHUB_TOKEN }} | |
- name: Setup Node version | |
uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d # pin@v3 | |
with: | |
node-version: 19 | |
- name: Install vsce globally | |
run: npm install -g @vscode/vsce | |
- name: Install dependencies | |
run: npm install | |
- name: Install webview dependencies | |
run: npm run install:webview | |
- name: Build webview | |
run: npm run build:webview | |
- name: Build Package | |
run: npm run compile | |
- name: Setup Kubernetes | |
uses: engineerd/setup-kind@aa272fe2a7309878ffc2a81c56cfe3ef108ae7d0 # [email protected] | |
with: | |
version: v0.20.0 | |
image: kindest/node:v1.28.0 | |
- name: Run Tests | |
uses: coactions/setup-xvfb@b6b4fcfb9f5a895edadc3bc76318fae0ac17c8b3 # pin@v1 | |
with: | |
run: npm test | |
options: "-screen 0 1600x1200x24" | |
- name: Create Changelog | |
run: | | |
git log $(git describe --tags --abbrev=0)..HEAD --oneline &> ${{ github.workspace }}-CHANGELOG.txt | |
cat ${{ github.workspace }}-CHANGELOG.txt | |
- name: Setup Git | |
run: | | |
git config --global user.name "gitops-release-bot" | |
git config --global user.email "[email protected]" | |
- name: Get Current Version Number | |
run: | | |
CURRENT_VERSION=$(cat package.json | jq .version | cut -d'"' -f 2) | |
echo "CURRENT_VERSION=$CURRENT_VERSION" >> $GITHUB_ENV | |
- name: Compile New Version (Edge) | |
run: | | |
RELEASE_VERSION=$(npx semver $CURRENT_VERSION -i pre${{ github.event.inputs.releaseType }} --preid edge) | |
echo "RELEASE_VERSION=$RELEASE_VERSION" >> $GITHUB_ENV | |
echo "Bump to $RELEASE_VERSION" | |
if: ${{ github.event.inputs.releaseChannel == 'edge' && !contains(env.CURRENT_VERSION, 'edge') }} | |
- name: Compile New Version (Edge) | |
run: | | |
RELEASE_VERSION=$(npx semver $CURRENT_VERSION -i prerelease) | |
echo "RELEASE_VERSION=$RELEASE_VERSION" >> $GITHUB_ENV | |
echo "Bump to $RELEASE_VERSION" | |
if: ${{ github.event.inputs.releaseChannel == 'edge' && contains(env.CURRENT_VERSION, 'edge') }} | |
- name: Compile New Version (Stable) | |
run: | | |
RELEASE_VERSION=$(npx semver $CURRENT_VERSION -i ${{ github.event.inputs.releaseType }}) | |
echo "RELEASE_VERSION=$RELEASE_VERSION" >> $GITHUB_ENV | |
echo "Bump to $RELEASE_VERSION" | |
if: ${{ github.event.inputs.releaseChannel == 'stable' }} | |
- name: Version Package | |
run: | | |
git status | |
git diff && git diff --cached | |
npm version $RELEASE_VERSION | |
git tag -a $RELEASE_VERSION -m "$RELEASE_VERSION" | |
- name: Package Extension (Edge) | |
if: ${{ github.event.inputs.releaseChannel == 'edge' }} | |
run: | | |
node .github/scripts/updateEdgeVersion.js | |
vsce package --pre-release --no-git-tag-version --no-update-package-json -o "./gitops-tools-$RELEASE_VERSION.vsix" ${{ github.event.inputs.additionalFlags }} | |
- name: Package Extension (Stable) | |
run: vsce package $RELEASE_VERSION --no-git-tag-version --no-update-package-json -o "./gitops-tools-$RELEASE_VERSION.vsix" ${{ github.event.inputs.additionalFlags }} | |
if: ${{ github.event.inputs.releaseChannel == 'stable' }} | |
- name: Publish to Visual Studio Marketplace (Edge) | |
run: vsce publish --packagePath "./gitops-tools-$RELEASE_VERSION.vsix" --pre-release --no-git-tag-version --no-update-package-json -p ${{ secrets.VSC_MKTP_PAT }} ${{ github.event.inputs.additionalFlags }} | |
if: ${{ github.event.inputs.publishMarketplace == 'yes' && github.event.inputs.releaseChannel == 'edge' }} | |
- name: Publish to Visual Studio Marketplace (Stable) | |
run: vsce publish --packagePath "./gitops-tools-$RELEASE_VERSION.vsix" --no-git-tag-version --no-update-package-json -p ${{ secrets.VSC_MKTP_PAT }} ${{ github.event.inputs.additionalFlags }} | |
if: ${{ github.event.inputs.publishMarketplace == 'yes' && github.event.inputs.releaseChannel == 'stable' }} | |
- name: Publish to Open VSX Registry (Edge) | |
uses: HaaLeo/publish-vscode-extension@dfe4f6ad46624424fe24cb5bca79839183399045 # pin@v1 | |
if: ${{ github.event.inputs.publishOpenVSX == 'yes' && github.event.inputs.releaseChannel == 'edge' }} | |
with: | |
preRelease: true | |
pat: ${{ secrets.OPEN_VSX_TOKEN }} | |
extensionFile: ./gitops-tools-${{ env.RELEASE_VERSION }}.vsix | |
- name: Publish to Open VSX Registry (Stable) | |
uses: HaaLeo/publish-vscode-extension@dfe4f6ad46624424fe24cb5bca79839183399045 # pin@v1 | |
if: ${{ github.event.inputs.publishOpenVSX == 'yes' && github.event.inputs.releaseChannel == 'stable' }} | |
with: | |
preRelease: false | |
pat: ${{ secrets.OPEN_VSX_TOKEN }} | |
extensionFile: ./gitops-tools-${{ env.RELEASE_VERSION }}.vsix | |
- name: Push Tags (Edge) | |
if: ${{ github.event.inputs.releaseChannel == 'edge' }} | |
run: | | |
git log -1 --stat | |
git push origin --force-with-lease edge:release-pr --tags | |
- name: Push Tags (Stable) | |
if: ${{ github.event.inputs.releaseChannel == 'stable' }} | |
run: | | |
git log -1 --stat | |
git push origin --force-with-lease main:release-pr --tags | |
- run: | | |
export GIT_TAG=$(git describe --tags --abbrev=0) | |
echo "GIT_TAG=$GIT_TAG" >> $GITHUB_ENV | |
- name: GitHub Release | |
uses: ncipollo/release-action@6c75be85e571768fa31b40abf38de58ba0397db5 # pin@v1 | |
with: | |
artifacts: "./gitops-tools-*" | |
bodyFile: ${{ github.workspace }}-CHANGELOG.txt | |
tag: ${{ env.GIT_TAG }} | |
prerelease: ${{ github.event.inputs.releaseChannel == 'edge' }} | |
# We need to use a pull request because we need tags to be included in the history of our main | |
# branch. We don't want to make an exception for our "no pushes without a pull request" security | |
# policy, even for some robot. So just merge this PR manually to complete each release, or do a | |
# fast-forward of the edge branch catching it up to the `release-pr` branch, as it won't get the | |
# PR. (If you have trouble publishing more than one edge release, this mistake is usually why.) | |
- uses: repo-sync/pull-request@7e79a9f5dc3ad0ce53138f01df2fad14a04831c5 # pin@v2 | |
name: Finish Release PR | |
if: ${{ github.event.inputs.releaseChannel != 'edge' }} | |
with: | |
source_branch: "release-pr" | |
destination_branch: "main" | |
pr_title: "Release ${{ env.GIT_TAG }}" | |
pr_body: |- | |
A release has been tagged and published, ${{ env.GIT_TAG }}! 🎉 | |
Please ensure that \`CHANGELOG.md\` remains current by pushing any needed updates as a commit to this branch. | |
A CHANGELOG has been generated for this release here, [\`v${{ env.GIT_TAG }}\`](https://github.com/weaveworks/vscode-gitops-tools/releases/tag/${{ env.GIT_TAG }}) – you can copy directly from it, or edit for uniformity and clarity. | |
When you are done, merge this PR with the tag intact (**Do Not Squash** or rebase! Push new commits and **merge only**). | |
Feature branches should still be squashed, but \`release-pr\` must always be merged to complete the release. | |
See the [CONTRIBUTING.md](https://github.com/weaveworks/vscode-gitops-tools/blob/main/CONTRIBUTING.md#releasing) for more information about the release process. | |
pr_reviewer: ${{ github.actor }} | |
pr_draft: false | |
github_token: ${{ secrets.GITHUB_TOKEN }} | |
# - name: Get the version | |
# id: version | |
# run: echo ::set-output name=VERSION::${GITHUB_REF/refs\/tags\//} | |
# shell: bash | |
# | |
# - uses: apexskier/github-semver-parse@671ddf80785e4d721e76723ec1e687317f85bfe9 # pin@v1 | |
# id: semver | |
# with: | |
# version: ${{ steps.version.outputs.VERSION }} | |
# | |
# - uses: ncipollo/release-action@58ae73b360456532aafd58ee170c045abbeaee37 # pin@v1 | |
# with: | |
# artifacts: "vscode-gitops-tools-*.vsix" | |
# token: ${{ secrets.GITHUB_TOKEN }} | |
# prerelease: ${{ !!steps.semver.outputs.prerelease }} |