-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Replace GitVersion with get-version.sh
- Loading branch information
Showing
4 changed files
with
69 additions
and
21 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,6 +17,10 @@ on: | |
jobs: | ||
# This workflow contains a single job called "build" | ||
build: | ||
env: | ||
RELEASE_FLAG: false | ||
LANGUAGESERVER_REF: "000000" | ||
|
||
# The type of runner that the job will run on | ||
runs-on: ubuntu-latest | ||
|
||
|
@@ -60,29 +64,16 @@ jobs: | |
- name: Run unit tests | ||
run: npm test | ||
|
||
- name: Install GitVersion | ||
uses: gittools/actions/gitversion/[email protected] | ||
with: | ||
versionSpec: "6.x" | ||
|
||
- name: Execute GitVersion | ||
id: gitversion # step id used as reference for output values | ||
uses: gittools/actions/gitversion/[email protected] | ||
|
||
- name: Print version information | ||
run: | | ||
echo "Major: ${{ steps.gitversion.outputs.major }}" | ||
echo "Minor: ${{ steps.gitversion.outputs.minor }}" | ||
echo "Patch: ${{ steps.gitversion.outputs.patch }}" | ||
echo "MajorMinorPatch: ${{ steps.gitversion.outputs.majorMinorPatch }}" | ||
echo "SemVer: ${{ steps.gitversion.outputs.semVer }}" | ||
- name: Get version | ||
id: version | ||
run: ./get-version.sh | ||
|
||
- name: Update metadata in package.json | ||
uses: onlyutkarsh/[email protected] | ||
with: | ||
files: "${{github.workspace}}/package.json" | ||
patch-syntax: | | ||
= /version => "${{ steps.gitversion.outputs.majorMinorPatch }}" | ||
= /version => "${{ steps.version.outputs.MajorMinorCommits }}" | ||
# If is a push, and the commit message does not contain the string | ||
# '[release]', build as pre-release. (This is used in the final step.) | ||
|
@@ -99,13 +90,13 @@ jobs: | |
- name: Upload .vsix as artifact | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: yarn-spinner-${{steps.gitversion.outputs.majorMinorPatch}}.vsix | ||
path: ${{github.workspace}}/yarn-spinner-${{steps.gitversion.outputs.majorMinorPatch}}.vsix | ||
name: yarn-spinner-${{steps.version.outputs.MajorMinorCommits}}.vsix | ||
path: ${{github.workspace}}/yarn-spinner-${{steps.version.outputs.MajorMinorCommits}}.vsix | ||
|
||
# If this is a push to the main branch, publish to the Marketplace using our configuration. | ||
- name: Publish to Marketplace | ||
if: success() && github.ref == 'refs/heads/main' && github.event_name == 'push' | ||
env: | ||
VSCE_PAT: ${{ secrets.VSCE_PAT }} | ||
run: | | ||
npx vsce publish ${{ env.RELEASE_FLAG }} -i ${{github.workspace}}/yarn-spinner-${{steps.gitversion.outputs.majorMinorPatch}}.vsix | ||
npx vsce publish ${{ env.RELEASE_FLAG }} -i ${{github.workspace}}/yarn-spinner-${{steps.version.outputs.MajorMinorCommits}}.vsix |
Empty file.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
#!/bin/bash | ||
|
||
# Get info about the current commit | ||
most_recent_tag=$(git describe --tags --match="v*" --abbrev=0) | ||
commits_since_tag=$(git rev-list $most_recent_tag..HEAD | wc -l | awk '{$1=$1};1') | ||
sha=$(git log -1 --format=%H) | ||
short_sha=$(git log -1 --format=%h) | ||
branch=$(git rev-parse --abbrev-ref HEAD) | ||
|
||
total_commit_count=$(git rev-list HEAD | wc -l | awk '{$1=$1};1') | ||
|
||
# A regex for extracting data from a version number: major, minor, patch, | ||
# [prerelease] | ||
REGEX='v(\d+)\.(\d+)\.(\d+)(-.*)?' | ||
|
||
raw_version=${1:-"$most_recent_tag"} | ||
|
||
# Extract the data from the version number | ||
major=$(echo $raw_version | perl -pe "s|$REGEX|\1|" ) | ||
minor=$(echo $raw_version | perl -pe "s|$REGEX|\2|" ) | ||
patch=$(echo $raw_version | perl -pe "s|$REGEX|\3|" ) | ||
prerelease=$(echo $raw_version | perl -pe "s|$REGEX|\4|" ) | ||
|
||
# Calculate the semver from the version (should be the same as the version, but | ||
# just in case) | ||
SemVer="$major.$minor.$patch$prerelease" | ||
|
||
MajorMinorCommits="$major.$minor.$total_commit_count" | ||
|
||
# If there are any commits since the current tag and we aren't overriding our | ||
# version, add that note | ||
if [ "$commits_since_tag" -gt 0 -a -z "$1" ]; then | ||
SemVer="$SemVer+$commits_since_tag" | ||
fi | ||
|
||
# Create the version strings we'll write into the AssemblyInfo files | ||
OutputAssemblyVersion=$(echo "$major.$minor.$patch.$commits_since_tag" | perl -pe "s|\/|\\\/|" ) | ||
OutputAssemblyInformationalVersion=$(echo "$SemVer.Branch.$branch.Sha.$sha" | perl -pe "s|\/|\\\/|" ) | ||
OutputAssemblyFileVersion=$(echo "$major.$minor.$patch.$commits_since_tag" | perl -pe "s|\/|\\\/|" ) | ||
|
||
# Update the AssemblyInfo.cs files | ||
for infoFile in $(find . -name "AssemblyInfo.cs"); do | ||
perl -pi -e "s/AssemblyVersion\(\".*\"\)/AssemblyVersion(\"$OutputAssemblyVersion\")/" $infoFile | ||
perl -pi -e "s/AssemblyInformationalVersion\(\".*\"\)/AssemblyInformationalVersion(\"$OutputAssemblyInformationalVersion\")/" $infoFile | ||
perl -pi -e "s/AssemblyFileVersion\(\".*\"\)/AssemblyFileVersion(\"$OutputAssemblyFileVersion\")/" $infoFile | ||
done | ||
|
||
# If we're running in GitHub Workflows, output our calculated SemVer | ||
if [[ -n $GITHUB_OUTPUT ]]; then | ||
echo "SemVer=$SemVer" >> "$GITHUB_OUTPUT" | ||
echo "ShortSha=$short_sha" >> "$GITHUB_OUTPUT" | ||
echo "MajorMinorCommits=$MajorMinorCommits" >> "$GITHUB_OUTPUT" | ||
fi | ||
|
||
# Log our SemVer | ||
echo $SemVer | ||
echo $MajorMinorCommits |
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