Skip to content

Commit

Permalink
[AXON-19] feat: nightly versioning & release scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
sdzh-atlassian committed Dec 4, 2024
1 parent 23bc418 commit 85c8ad2
Show file tree
Hide file tree
Showing 5 changed files with 145 additions and 18 deletions.
56 changes: 46 additions & 10 deletions .github/workflows/release-nightly.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,31 +3,38 @@ name: Release Nightly
on:
schedule:
- cron: '0 0 * * *'
workflow_call: {}
# Can be triggered manually if needed
workflow_dispatch: {}

jobs:
release:
release-nightly:

runs-on: ubuntu-latest

permissions:
contents: write

steps:
- uses: actions/checkout@v4

# TODO if we want to publish this, just a different version is not enough
# We'd probably want to use a different id for the extension, too - e.g. atlascode-nightly
- name: Evaluate version
run: |
RELEASE_VERSION=$(./nightlyver.sh ${GITHUB_SHA}) && \
echo "RELEASE_VERSION=${RELEASE_VERSION}" >> $GITHUB_ENV && \
echo "Using version '${RELEASE_VERSION}'"
- name: Set version
run: npm -no-git-tag-version --allow-same-version -f version $RELEASE_VERSION
PACKAGE_VERSION=$(./scripts/version/get-next-nightly.sh)
echo "PACKAGE_VERSION=${PACKAGE_VERSION}" >> $GITHUB_ENV
echo "RELEASE_TAG=v${PACKAGE_VERSION}" >> $GITHUB_ENV
echo "Using version '${PACKAGE_VERSION}'"
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: 20
cache: 'npm'

- name: Set version
run: |
npm -no-git-tag-version --allow-same-version -f version $RELEASE_VERSION
- name: Install dependencies
run: npm install

Expand All @@ -40,4 +47,33 @@ jobs:
- name: Build the extension
run: npm run extension:package

# No publish actions here for the time being - let's get the builds going first
# No VSCE/OVSX publish actions here for the time being - let's get the builds going first

- name: Create Tag
run: |
git config --global user.email "[email protected]"
git config --global user.name "Nightly Release Bot"
git tag -a $RELEASE_TAG -m "Nightly build for $(date +'%Y-%m-%d %H:%M')"
git push origin $RELEASE_TAG
- name: Create Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ env.RELEASE_TAG }}
release_name: Release ${{ env.RELEASE_TAG }}
draft: false
prerelease: true

- name: Upload Release Assets
id: upload-release-asset
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./atlascode-${{ env.PACKAGE_VERSION }}.vsix
asset_name: atlascode-${{ env.PACKAGE_VERSION }}.vsix
asset_content_type: application/zip
52 changes: 44 additions & 8 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,27 +3,42 @@ name: Release
on:
push:
tags:
- 'v*'
- '!*nightly*'
branches:
- '**'

jobs:
release-nightly:
uses: ./.github/workflows/release-nightly.yaml

release:
runs-on: ubuntu-latest

# Release the next `nightly` before a stable version
# to prvent folks on pre-releases from being downgraded
needs: release-nightly

permissions:
contents: write

steps:

- uses: actions/checkout@v4

- name: Evaluate version
run: |
PACKAGE_VERSION=${GITHUB_REF##*/v}
echo "PACKAGE_VERSION=${PACKAGE_VERSION}" >> $GITHUB_ENV
echo "RELEASE_TAG=v${PACKAGE_VERSION}" >> $GITHUB_ENV
echo "Using version '${PACKAGE_VERSION}'"
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: 20
cache: 'npm'

- name: Evaluate version
run: |
RELEASE_VERSION=${GITHUB_REF##*/v} && \
echo "RELEASE_VERSION=${RELEASE_VERSION}" >> $GITHUB_ENV && \
echo "Using version '${RELEASE_VERSION}'"
- name: Set version
run: npm -no-git-tag-version --allow-same-version -f version $RELEASE_VERSION

Expand Down Expand Up @@ -52,12 +67,33 @@ jobs:
# echo npx vsce publish \
# -p ${{ secrets.VSCE_MARKETPLACE_TOKEN }} \
# --baseContentUrl https://bitbucket.org/atlassianlabs/atlascode/src/main/ \
# --packagePath atlascode-${GITHUB_REF##*/v}.vsix
# --packagePath atlascode-${PACKAGE_VERSION}.vsix
- name: Publish to OpenVSX
run: |
npx ovsx verify-pat -p ${{ secrets.OPENVSX_KEY }}
# echo npx ovsx publish \
# -p ${{ secrets.OPENVSX_KEY }} \
# "atlascode-${GITHUB_REF##*/v}.vsix"
# "atlascode-${PACKAGE_VERSION}.vsix"
- name: Create Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ env.RELEASE_TAG }}
release_name: Release ${{ env.RELEASE_TAG }}
draft: false
prerelease: false

- name: Upload Release Assets
id: upload-release-asset
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./atlascode-${{ env.PACKAGE_VERSION }}.vsix
asset_name: atlascode-${{ env.PACKAGE_VERSION }}.vsix
asset_content_type: application/zip
13 changes: 13 additions & 0 deletions scripts/version/get-latest-nightly.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/usr/bin/env bash

n_release=${1:-1}

# Get latest nightly tag from the repository
# Pre-releases are defined by the version number having an ODD minor number
# https://code.visualstudio.com/api/working-with-extensions/publishing-extension#prerelease-extensions
git tag --list | \
sort --version-sort -r | \
grep -E '^v[0-9]+\.[0-9]*[13579]\.[0-9]+.*' | \
head -n $n_release | \
tail -n 1 | \
cut -c 2-
13 changes: 13 additions & 0 deletions scripts/version/get-latest-stable.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/usr/bin/env bash

n_release=${1:-1}

# Get latest release tag from the repository
# Stable releases are defined by the version number having an EVEN minor number
# https://code.visualstudio.com/api/working-with-extensions/publishing-extension#prerelease-extensions
git tag --list | \
sort --version-sort -r | \
grep -E '^v[0-9]+\.[0-9]*[02468]\.[0-9]+$' | \
head -n $n_release | \
tail -n 1 | \
cut -c 2-
29 changes: 29 additions & 0 deletions scripts/version/get-next-nightly.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#!/usr/bin/env bash

# Nightly version is defined by the latest stable release tag,
# except the minor version is incremented by one
# https://code.visualstudio.com/api/working-with-extensions/publishing-extension#prerelease-extensions

git fetch --tags -q
latest_stable_version=$(./scripts/version/get-latest-stable.sh)
latest_nightly_version=$(./scripts/version/get-latest-nightly.sh)

# Major version is the same as the latest stable version
stable_major=$(echo $latest_stable_version | cut -d '.' -f 1)
nightly_major=$(echo $latest_nightly_version | cut -d '.' -f 1)

# Minor version is always "latest stable + 1"
stable_minor=$(echo $latest_stable_version | cut -d '.' -f 2)
nightly_minor=$(echo $latest_nightly_version | cut -d '.' -f 2)
next_minor=$((stable_minor + 1))

# Patch is incrementing, unless we're on a new minor
if [[ $nightly_major -eq $stable_major && $next_minor -eq $nightly_minor ]]; then
nightly_patch=$(echo $latest_nightly_version | cut -d '.' -f 3 | cut -d '-' -f 1)
nightly_patch=${nightly_patch:--1} # In case of new nightly minor
next_patch=$((nightly_patch + 1))
else
next_patch=0
fi

echo "$stable_major.$next_minor.$next_patch-nightly"

0 comments on commit 85c8ad2

Please sign in to comment.