Skip to content

Commit c43983b

Browse files
[AXON-19] feat: nightly versioning & release scripts
1 parent eb2b2a6 commit c43983b

7 files changed

+171
-20
lines changed

.github/workflows/release-nightly.yaml

+47-10
Original file line numberDiff line numberDiff line change
@@ -3,31 +3,39 @@ name: Release Nightly
33
on:
44
schedule:
55
- cron: '0 0 * * *'
6+
workflow_call: {}
7+
# Can be triggered manually if needed
8+
workflow_dispatch: {}
69

710
jobs:
8-
release:
11+
release-nightly:
12+
913
runs-on: ubuntu-latest
1014

15+
permissions:
16+
contents: write
17+
1118
steps:
1219
- uses: actions/checkout@v4
1320

14-
# TODO if we want to publish this, just a different version is not enough
15-
# We'd probably want to use a different id for the extension, too - e.g. atlascode-nightly
1621
- name: Evaluate version
1722
run: |
18-
RELEASE_VERSION=$(./nightlyver.sh ${GITHUB_SHA}) && \
19-
echo "RELEASE_VERSION=${RELEASE_VERSION}" >> $GITHUB_ENV && \
20-
echo "Using version '${RELEASE_VERSION}'"
21-
22-
- name: Set version
23-
run: npm -no-git-tag-version --allow-same-version -f version $RELEASE_VERSION
23+
PACKAGE_VERSION=$(./scripts/version/get-next-nightly.sh)
24+
./scripts/version/assert-nightly.sh $PACKAGE_VERSION
25+
echo "PACKAGE_VERSION=${PACKAGE_VERSION}" >> $GITHUB_ENV
26+
echo "RELEASE_TAG=v${PACKAGE_VERSION}" >> $GITHUB_ENV
27+
echo "Using version '${PACKAGE_VERSION}'"
2428
2529
- name: Set up Node.js
2630
uses: actions/setup-node@v4
2731
with:
2832
node-version: 20
2933
cache: 'npm'
3034

35+
- name: Set version
36+
run: |
37+
npm -no-git-tag-version --allow-same-version -f version $PACKAGE_VERSION
38+
3139
- name: Install dependencies
3240
run: npm install
3341

@@ -40,4 +48,33 @@ jobs:
4048
- name: Build the extension
4149
run: npm run extension:package
4250

43-
# No publish actions here for the time being - let's get the builds going first
51+
# No VSCE/OVSX publish actions here for the time being - let's get the builds going first
52+
53+
- name: Create Tag
54+
run: |
55+
git config --global user.email "[email protected]"
56+
git config --global user.name "Nightly Release Bot"
57+
git tag -a $RELEASE_TAG -m "Nightly build for $(date +'%Y-%m-%d %H:%M')"
58+
git push origin $RELEASE_TAG
59+
60+
- name: Create Release
61+
id: create_release
62+
uses: actions/create-release@v1
63+
env:
64+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
65+
with:
66+
tag_name: ${{ env.RELEASE_TAG }}
67+
release_name: Release ${{ env.RELEASE_TAG }}
68+
draft: false
69+
prerelease: true
70+
71+
- name: Upload Release Assets
72+
id: upload-release-asset
73+
uses: actions/upload-release-asset@v1
74+
env:
75+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
76+
with:
77+
upload_url: ${{ steps.create_release.outputs.upload_url }}
78+
asset_path: ./atlascode-${{ env.PACKAGE_VERSION }}.vsix
79+
asset_name: atlascode-${{ env.PACKAGE_VERSION }}.vsix
80+
asset_content_type: application/zip

.github/workflows/release.yaml

+45-10
Original file line numberDiff line numberDiff line change
@@ -3,29 +3,43 @@ name: Release
33
on:
44
push:
55
tags:
6-
- '**'
6+
- 'v*'
7+
- '!*nightly*'
78

89
jobs:
10+
release-nightly:
11+
uses: ./.github/workflows/release-nightly.yaml
12+
913
release:
1014
runs-on: ubuntu-latest
15+
16+
# Release the next `nightly` before a stable version
17+
# to prvent folks on pre-releases from being downgraded
18+
needs: release-nightly
19+
20+
permissions:
21+
contents: write
22+
1123
steps:
1224

1325
- uses: actions/checkout@v4
1426

27+
- name: Evaluate version
28+
run: |
29+
PACKAGE_VERSION=${GITHUB_REF##*/v}
30+
./scripts/version/assert-stable.sh $PACKAGE_VERSION
31+
echo "PACKAGE_VERSION=${PACKAGE_VERSION}" >> $GITHUB_ENV
32+
echo "RELEASE_TAG=v${PACKAGE_VERSION}" >> $GITHUB_ENV
33+
echo "Using version '${PACKAGE_VERSION}'"
34+
1535
- name: Set up Node.js
1636
uses: actions/setup-node@v4
1737
with:
1838
node-version: 20
1939
cache: 'npm'
2040

21-
- name: Evaluate version
22-
run: |
23-
RELEASE_VERSION=${GITHUB_REF##*/v} && \
24-
echo "RELEASE_VERSION=${RELEASE_VERSION}" >> $GITHUB_ENV && \
25-
echo "Using version '${RELEASE_VERSION}'"
26-
2741
- name: Set version
28-
run: npm -no-git-tag-version --allow-same-version -f version $RELEASE_VERSION
42+
run: npm -no-git-tag-version --allow-same-version -f version $PACKAGE_VERSION
2943

3044
- name: Install dependencies
3145
run: npm install
@@ -52,12 +66,33 @@ jobs:
5266
# echo npx vsce publish \
5367
# -p ${{ secrets.VSCE_MARKETPLACE_TOKEN }} \
5468
# --baseContentUrl https://bitbucket.org/atlassianlabs/atlascode/src/main/ \
55-
# --packagePath atlascode-${GITHUB_REF##*/v}.vsix
69+
# --packagePath atlascode-${PACKAGE_VERSION}.vsix
5670
5771
- name: Publish to OpenVSX
5872
run: |
5973
npx ovsx verify-pat -p ${{ secrets.OPENVSX_KEY }}
6074
# echo npx ovsx publish \
6175
# -p ${{ secrets.OPENVSX_KEY }} \
62-
# "atlascode-${GITHUB_REF##*/v}.vsix"
76+
# "atlascode-${PACKAGE_VERSION}.vsix"
6377
78+
- name: Create Release
79+
id: create_release
80+
uses: actions/create-release@v1
81+
env:
82+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
83+
with:
84+
tag_name: ${{ env.RELEASE_TAG }}
85+
release_name: Release ${{ env.RELEASE_TAG }}
86+
draft: false
87+
prerelease: false
88+
89+
- name: Upload Release Assets
90+
id: upload-release-asset
91+
uses: actions/upload-release-asset@v1
92+
env:
93+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
94+
with:
95+
upload_url: ${{ steps.create_release.outputs.upload_url }}
96+
asset_path: ./atlascode-${{ env.PACKAGE_VERSION }}.vsix
97+
asset_name: atlascode-${{ env.PACKAGE_VERSION }}.vsix
98+
asset_content_type: application/zip

scripts/version/assert-nightly.sh

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#!/usr/bin/env bash
2+
3+
# Make sure that the minor version is odd
4+
version=$1
5+
6+
if [[ $version =~ ^[0-9]+\.[0-9]*[13579]\.[0-9]+.*$ ]]; then
7+
echo "Version $version is a valid pre-release (odd minor version)"
8+
exit 0
9+
else
10+
echo "Version $version is not a valid pre-release (even minor version or invalid format)"
11+
exit 1
12+
fi

scripts/version/assert-stable.sh

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#!/usr/bin/env bash
2+
3+
# Make sure that the minor version is even
4+
version=$1
5+
6+
if [[ $version =~ ^[0-9]+\.[0-9]*[02468]\.[0-9]+$ ]]; then
7+
echo "Version $version is a valid stable release (even minor version)"
8+
exit 0
9+
else
10+
echo "Version $version is not a valid stable release (odd minor version or invalid format)"
11+
exit 1
12+
fi

scripts/version/get-latest-nightly.sh

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#!/usr/bin/env bash
2+
3+
n_release=${1:-1}
4+
5+
# Get latest nightly tag from the repository
6+
# Pre-releases are defined by the version number having an ODD minor number
7+
# https://code.visualstudio.com/api/working-with-extensions/publishing-extension#prerelease-extensions
8+
git tag --list | \
9+
sort --version-sort -r | \
10+
grep -E '^v[0-9]+\.[0-9]*[13579]\.[0-9]+.*' | \
11+
head -n $n_release | \
12+
tail -n 1 | \
13+
cut -c 2-

scripts/version/get-latest-stable.sh

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#!/usr/bin/env bash
2+
3+
n_release=${1:-1}
4+
5+
# Get latest release tag from the repository
6+
# Stable releases are defined by the version number having an EVEN minor number
7+
# https://code.visualstudio.com/api/working-with-extensions/publishing-extension#prerelease-extensions
8+
git tag --list | \
9+
sort --version-sort -r | \
10+
grep -E '^v[0-9]+\.[0-9]*[02468]\.[0-9]+$' | \
11+
head -n $n_release | \
12+
tail -n 1 | \
13+
cut -c 2-

scripts/version/get-next-nightly.sh

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
#!/usr/bin/env bash
2+
3+
# Nightly version is defined by the latest stable release tag,
4+
# except the minor version is incremented by one
5+
# https://code.visualstudio.com/api/working-with-extensions/publishing-extension#prerelease-extensions
6+
7+
git fetch --tags -q
8+
latest_stable_version=$(./scripts/version/get-latest-stable.sh)
9+
latest_nightly_version=$(./scripts/version/get-latest-nightly.sh)
10+
11+
# Major version is the same as the latest stable version
12+
stable_major=$(echo $latest_stable_version | cut -d '.' -f 1)
13+
nightly_major=$(echo $latest_nightly_version | cut -d '.' -f 1)
14+
15+
# Minor version is always "latest stable + 1"
16+
stable_minor=$(echo $latest_stable_version | cut -d '.' -f 2)
17+
nightly_minor=$(echo $latest_nightly_version | cut -d '.' -f 2)
18+
next_minor=$((stable_minor + 1))
19+
20+
# Patch is incrementing, unless we're on a new minor
21+
if [[ $nightly_major -eq $stable_major && $next_minor -eq $nightly_minor ]]; then
22+
nightly_patch=$(echo $latest_nightly_version | cut -d '.' -f 3 | cut -d '-' -f 1)
23+
nightly_patch=${nightly_patch:--1} # In case of new nightly minor
24+
next_patch=$((nightly_patch + 1))
25+
else
26+
next_patch=0
27+
fi
28+
29+
echo "$stable_major.$next_minor.$next_patch-nightly"

0 commit comments

Comments
 (0)