Skip to content

Automatic release on tag push #564

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

Merged
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
2 changes: 1 addition & 1 deletion .github/workflows/bump-version.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ let newVersion = latestPublish;

// If the main release gets a major bump but did not get published yet, the package.json version
// will be higher than the one retrieved from the marketplace, so we need to increment from the main release
// E.g. package.json gets bumped to 1.5.0 -> 1.6.0
// E.g. package.json gets bumped from 1.6.0 -> 2.0.0
if (semver.major(release) - semver.major(latestPublish) === 1) {
newVersion = semver.inc(release, "minor", semver.rel);
}
Expand Down
44 changes: 33 additions & 11 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ name: CI
on:
push:
branches: [ master ]
tags: "*.*.*"
pull_request:
branches: [ master ]

Expand Down Expand Up @@ -127,28 +128,30 @@ jobs:
COMMIT_SHA: ${{ github.event.pull_request.head.sha || github.sha }}
run: echo "::set-output name=sha_short::${COMMIT_SHA:0:7}"

- name: Get current pre-release version
if: github.ref == 'refs/heads/master'
id: get_pre_release
run: |
JSON=$(npx vsce show chenglou92.rescript-vscode --json)
VERSION=$(echo $JSON | jq '.versions | .[0] | .["version"]')
echo "::set-output name=current_version::${VERSION}"
- name: Store tag name
id: tag_name
if: startsWith(github.ref, 'refs/tags/')
run: echo ::set-output name=tag::${GITHUB_REF#refs/*/}

- name: Increment pre-release version
if: github.ref == 'refs/heads/master'
id: increment_pre_release
run: |
NEW_VERSION=$(echo ${{ steps.get_pre_release.outputs.current_version }})
JSON=$(npx vsce show chenglou92.rescript-vscode --json)
NEW_VERSION=$(echo $JSON | jq '.versions | .[0] | .["version"]')
node .github/workflows/bump-version.js ${NEW_VERSION}

- name: Package Extension
if: github.ref != 'refs/heads/master'
run: npx vsce package -o rescript-vscode-${{ steps.vars.outputs.sha_short }}.vsix
run: npx vsce package -o rescript-vscode-${{ steps.vars.outputs.sha_short }}.vsix

- name: Package Extension
- name: Package Extension pre-release version
if: github.ref == 'refs/heads/master'
run: npx vsce package -o rescript-vscode-${{ steps.increment_pre_release.outputs.new_version }}.vsix ${{ steps.increment_pre_release.outputs.new_version }} --no-git-tag-version
run: npx vsce package -o rescript-vscode-${{ steps.increment_pre_release.outputs.new_version }}.vsix ${{ steps.increment_pre_release.outputs.new_version }} --no-git-tag-version

- name: Package Extension release version
if: startsWith(github.ref, 'refs/tags/')
run: npx vsce package -o rescript-vscode-${{ steps.tag_name.outputs.tag }}.vsix ${{ steps.tag_name.outputs.tag }} --no-git-tag-version

- uses: actions/upload-artifact@v2
if: github.ref != 'refs/heads/master'
Expand All @@ -161,6 +164,12 @@ jobs:
with:
name: rescript-vscode-${{ steps.increment_pre_release.outputs.new_version }}.vsix
path: rescript-vscode-${{ steps.increment_pre_release.outputs.new_version }}.vsix

- uses: actions/upload-artifact@v2
if: startsWith(github.ref, 'refs/tags/')
with:
name: rescript-vscode-${{ steps.tag_name.outputs.tag }}.vsix
path: rescript-vscode-${{ steps.tag_name.outputs.tag }}.vsix

- name: Publish latest master to GitHub
if: github.ref == 'refs/heads/master'
Expand All @@ -172,6 +181,19 @@ jobs:
title: "Latest master"
files: rescript-vscode-${{ steps.increment_pre_release.outputs.new_version }}.vsix

- name: Publish release version to GitHub
if: startsWith(github.ref, 'refs/tags/')
uses: marvinpinto/action-automatic-releases@latest
with:
repo_token: "${{ secrets.GITHUB_TOKEN }}"
prerelease: false
title: ${{ steps.tag_name.outputs.tag }}
files: rescript-vscode-${{ steps.tag_name.outputs.tag }}.vsix

- name: Publish extension as pre-release
if: github.ref == 'refs/heads/master'
run: npx vsce publish --pat ${{ secrets.MARKETPLACE_TOKEN }} --pre-release ${{ steps.increment_pre_release.outputs.new_version }} --no-git-tag-version

- name: Publish extension as release
if: startsWith(github.ref, 'refs/tags/')
run: npx vsce publish --pat ${{ secrets.MARKETPLACE_TOKEN }} ${{ steps.tag_name.outputs.tag }} --no-git-tag-version
14 changes: 11 additions & 3 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -182,8 +182,16 @@ We're happy to gather more resources over time here, including more in-depth get

1. Bump the version properly in `package.json` and `server/package.json` and their lockfiles. Commit and push the version bump.
2. Make sure @ryyppy is aware of your changes. He needs to sync them over to the vim plugin.
3. Let CI build your version bump commit. Download the autogenerated `.vsix` from that CI run, unzip it, and rename it to `rescript-vscode-<version-number>.vsix` (`rescript-vscode-1.3.0.vsix` for example).
4. Go to the appropriate [VSCode Marketplace Publisher](https://marketplace.visualstudio.com/manage/publishers/chenglou92), select the three dots next to the extension name, and choose `Update`. Upload your `.vsix` there.
5. Not done! Make a new manual release [here](https://github.com/rescript-lang/rescript-vscode/releases), and make sure you attach the generated `.vsix` onto that new release as well. This is for folks who don't use the VSCode marketplace.
3. Let CI build your version bump commit.
4. Tag the commit with the version number (e.g. `git tag 1.6.0`) and push the tag (e.g. `git push origin 1.6.0`). Another build will trigger, which should automatically:
- create a `rescript-vscode-<version-number>.vsix` file
- publish that extension version to the VSCode marketplace
- create an automatic release on GitHub

If that somehow does not work, you can do the above steps manually:

1. Download the autogenerated `.vsix` from the previous successful CI run, unzip it, and rename it to `rescript-vscode-<version-number>.vsix` (`rescript-vscode-1.3.0.vsix` for example).
2. Go to the appropriate [VSCode Marketplace Publisher](https://marketplace.visualstudio.com/manage/publishers/chenglou92), select the three dots next to the extension name, and choose `Update`. Upload your `.vsix` there.
3. Not done! Make a new manual release [here](https://github.com/rescript-lang/rescript-vscode/releases), and make sure you attach the generated `.vsix` onto that new release as well. This is for folks who don't use the VSCode marketplace.

For beta releases, ask folks to try the `.vsix` from CI directly.