Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 2d1694b

Browse files
committedDec 4, 2024·
[AXON-19] feat: nightly versioning & release scripts
1 parent 23bc418 commit 2d1694b

File tree

5 files changed

+146
-19
lines changed

5 files changed

+146
-19
lines changed
 

‎.github/workflows/release-nightly.yaml

+46-10
Original file line numberDiff line numberDiff line change
@@ -3,31 +3,38 @@ 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+
echo "PACKAGE_VERSION=${PACKAGE_VERSION}" >> $GITHUB_ENV
25+
echo "RELEASE_TAG=v${PACKAGE_VERSION}" >> $GITHUB_ENV
26+
echo "Using version '${PACKAGE_VERSION}'"
2427
2528
- name: Set up Node.js
2629
uses: actions/setup-node@v4
2730
with:
2831
node-version: 20
2932
cache: 'npm'
3033

34+
- name: Set version
35+
run: |
36+
npm -no-git-tag-version --allow-same-version -f version $PACKAGE_VERSION
37+
3138
- name: Install dependencies
3239
run: npm install
3340

@@ -40,4 +47,33 @@ jobs:
4047
- name: Build the extension
4148
run: npm run extension:package
4249

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

‎.github/workflows/release.yaml

+45-9
Original file line numberDiff line numberDiff line change
@@ -3,29 +3,44 @@ name: Release
33
on:
44
push:
55
tags:
6+
- 'v*'
7+
- '!*nightly*'
8+
branches:
69
- '**'
710

811
jobs:
12+
release-nightly:
13+
uses: ./.github/workflows/release-nightly.yaml
14+
915
release:
1016
runs-on: ubuntu-latest
17+
18+
# Release the next `nightly` before a stable version
19+
# to prvent folks on pre-releases from being downgraded
20+
needs: release-nightly
21+
22+
permissions:
23+
contents: write
24+
1125
steps:
1226

1327
- uses: actions/checkout@v4
1428

29+
- name: Evaluate version
30+
run: |
31+
PACKAGE_VERSION=${GITHUB_REF##*/v}
32+
echo "PACKAGE_VERSION=${PACKAGE_VERSION}" >> $GITHUB_ENV
33+
echo "RELEASE_TAG=v${PACKAGE_VERSION}" >> $GITHUB_ENV
34+
echo "Using version '${PACKAGE_VERSION}'"
35+
1536
- name: Set up Node.js
1637
uses: actions/setup-node@v4
1738
with:
1839
node-version: 20
1940
cache: 'npm'
2041

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-
2742
- name: Set version
28-
run: npm -no-git-tag-version --allow-same-version -f version $RELEASE_VERSION
43+
run: npm -no-git-tag-version --allow-same-version -f version $PACKAGE_VERSION
2944

3045
- name: Install dependencies
3146
run: npm install
@@ -52,12 +67,33 @@ jobs:
5267
# echo npx vsce publish \
5368
# -p ${{ secrets.VSCE_MARKETPLACE_TOKEN }} \
5469
# --baseContentUrl https://bitbucket.org/atlassianlabs/atlascode/src/main/ \
55-
# --packagePath atlascode-${GITHUB_REF##*/v}.vsix
70+
# --packagePath atlascode-${PACKAGE_VERSION}.vsix
5671
5772
- name: Publish to OpenVSX
5873
run: |
5974
npx ovsx verify-pat -p ${{ secrets.OPENVSX_KEY }}
6075
# echo npx ovsx publish \
6176
# -p ${{ secrets.OPENVSX_KEY }} \
62-
# "atlascode-${GITHUB_REF##*/v}.vsix"
77+
# "atlascode-${PACKAGE_VERSION}.vsix"
6378
79+
- name: Create Release
80+
id: create_release
81+
uses: actions/create-release@v1
82+
env:
83+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
84+
with:
85+
tag_name: ${{ env.RELEASE_TAG }}
86+
release_name: Release ${{ env.RELEASE_TAG }}
87+
draft: false
88+
prerelease: false
89+
90+
- name: Upload Release Assets
91+
id: upload-release-asset
92+
uses: actions/upload-release-asset@v1
93+
env:
94+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
95+
with:
96+
upload_url: ${{ steps.create_release.outputs.upload_url }}
97+
asset_path: ./atlascode-${{ env.PACKAGE_VERSION }}.vsix
98+
asset_name: atlascode-${{ env.PACKAGE_VERSION }}.vsix
99+
asset_content_type: application/zip

‎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)
Please sign in to comment.