Skip to content

refactor: get version dynamically #5753

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 30 commits into from
Nov 8, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
cad9a41
refactor: get version dynamically
jsjoeio Nov 4, 2022
42d4029
chore: remove version
jsjoeio Nov 4, 2022
0b31a43
fixup: missing quotes
jsjoeio Nov 4, 2022
25e5f63
refactor: drop global VERSION
jsjoeio Nov 4, 2022
784ad56
wip: updating ersion in publish
jsjoeio Nov 4, 2022
ea99731
refactor: update publish.yaml with version changes
jsjoeio Nov 4, 2022
81d4f7f
refactor: release.yaml with new version changes
jsjoeio Nov 4, 2022
e09a263
refactor: update build.yaml with version changes
jsjoeio Nov 4, 2022
599587e
chore: update maintainer
jsjoeio Nov 4, 2022
06b89aa
fixup: update version in build-vscode
jsjoeio Nov 4, 2022
9749c68
fixup: fix github env version
jsjoeio Nov 4, 2022
4264a23
try macos only
jsjoeio Nov 4, 2022
056acae
try again
jsjoeio Nov 4, 2022
0ae3d03
last resort
jsjoeio Nov 4, 2022
9a34495
joe again
jsjoeio Nov 4, 2022
6dcc175
this oneee
jsjoeio Nov 4, 2022
413c005
fixup: this should work
jsjoeio Nov 4, 2022
83c0801
try using inputs
jsjoeio Nov 4, 2022
5e4642e
docs: update release notes
jsjoeio Nov 4, 2022
3efac18
fixup!: use env.VERSION in docker step
jsjoeio Nov 7, 2022
9cd480b
fixup!: comment get and set version
jsjoeio Nov 7, 2022
e503fa4
fixup!: remove compress release package comment
jsjoeio Nov 7, 2022
c08c0b7
fixup!: use $VERSION in npm-version
jsjoeio Nov 7, 2022
c2c0afa
Merge branch 'main' into jsjoeio/release-changes
jsjoeio Nov 7, 2022
7aa1784
refactor: set VERSION in build VS Code step
jsjoeio Nov 7, 2022
d9ff180
refactor: use 0.0.0 in package.json version
jsjoeio Nov 7, 2022
aabbe5e
refactor: delete release-prep script
jsjoeio Nov 7, 2022
9b41f78
Merge branch 'main' into jsjoeio/release-changes
jsjoeio Nov 7, 2022
17f16b7
Update ci/build/build-vscode.sh
jsjoeio Nov 8, 2022
2b77611
fixup!: remove extra VERSION set in aur
jsjoeio Nov 8, 2022
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
14 changes: 9 additions & 5 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -187,10 +187,6 @@ jobs:
id: vscode-rev
run: echo "::set-output name=rev::$(git rev-parse HEAD:./lib/vscode)"

- name: Get version
id: version
run: echo "::set-output name=version::$(jq -r .version package.json)"

# We need to rebuild when we have a new version of Code, when any of
# the patches changed, or when the code-server version changes (since
# it gets embedded into the code). Use VSCODE_CACHE_VERSION to
Expand All @@ -200,9 +196,11 @@ jobs:
uses: actions/cache@v3
with:
path: lib/vscode-reh-web-*
key: vscode-reh-package-${{ secrets.VSCODE_CACHE_VERSION }}-${{ steps.vscode-rev.outputs.rev }}-${{ steps.version.outputs.version }}-${{ hashFiles('patches/*.diff', 'ci/build/build-vscode.sh') }}
key: vscode-reh-package-${{ secrets.VSCODE_CACHE_VERSION }}-${{ steps.vscode-rev.outputs.rev }}-${{ hashFiles('patches/*.diff', 'ci/build/build-vscode.sh') }}

- name: Build vscode
env:
VERSION: "0.0.0"
if: steps.cache-vscode.outputs.cache-hit != 'true'
run: yarn build:vscode

Expand Down Expand Up @@ -261,6 +259,12 @@ jobs:
- name: Run ./ci/steps/publish-npm.sh
run: yarn publish:npm
env:
# NOTE@jsjoeio
# This is because npm enforces semantic versioning
# so it has to be a valid version. We only use this
# to publish dev versions from prs
# and beta versions from main.
VERSION: "0.0.0"
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
# NOTE@jsjoeio
Expand Down
57 changes: 40 additions & 17 deletions .github/workflows/publish.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@ on:
# Shows the manual trigger in GitHub UI
# helpful as a back-up in case the GitHub Actions Workflow fails
workflow_dispatch:
inputs:
version:
description: The version to publish (include "v", i.e. "v4.9.1").
type: string
required: true

release:
types: [released]
Expand All @@ -24,21 +29,25 @@ jobs:
- name: Checkout code-server
uses: actions/checkout@v3

- name: Get version
id: version
run: echo "::set-output name=version::$(jq -r .version package.json)"

- name: Download npm package from release artifacts
uses: robinraju/[email protected]
with:
repository: "coder/code-server"
tag: v${{ steps.version.outputs.version }}
tag: ${{ github.event.inputs.version || github.ref_name }}
fileName: "package.tar.gz"
out-file-path: "release-npm-package"

# NOTE@jsjoeio - we do this so we can strip out the v
# i.e. v4.9.1 -> 4.9.1
- name: Get and set VERSION
run: |
TAG="${{ github.event.inputs.version || github.ref_name }}"
echo "VERSION=${TAG#v}" >> $GITHUB_ENV

- name: Publish npm package and tag with "latest"
run: yarn publish:npm
env:
VERSION: ${{ env.VERSION }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
NPM_ENVIRONMENT: "production"
Expand All @@ -62,9 +71,18 @@ jobs:
git config --global user.name cdrci
git config --global user.email [email protected]

# NOTE@jsjoeio - we do this so we can strip out the v
# i.e. v4.9.1 -> 4.9.1
- name: Get and set VERSION
run: |
TAG="${{ github.event.inputs.version || github.ref_name }}"
echo "VERSION=${TAG#v}" >> $GITHUB_ENV

- name: Bump code-server homebrew version
env:
VERSION: ${{ env.VERSION }}
HOMEBREW_GITHUB_API_TOKEN: ${{secrets.HOMEBREW_GITHUB_API_TOKEN}}

run: ./ci/steps/brew-bump.sh

aur:
Expand All @@ -73,6 +91,7 @@ jobs:
timeout-minutes: 10
env:
GH_TOKEN: ${{ secrets.HOMEBREW_GITHUB_API_TOKEN }}

steps:
# We need to checkout code-server so we can get the version
- name: Checkout code-server
Expand All @@ -81,13 +100,6 @@ jobs:
fetch-depth: 0
path: "./code-server"

- name: Get code-server version
id: version
run: |
pushd code-server
echo "::set-output name=version::$(jq -r .version package.json)"
popd

- name: Checkout code-server-aur repo
uses: actions/checkout@v3
with:
Expand All @@ -106,10 +118,17 @@ jobs:
git config --global user.name cdrci
git config --global user.email [email protected]

# NOTE@jsjoeio - we do this so we can strip out the v
# i.e. v4.9.1 -> 4.9.1
- name: Get and set VERSION
run: |
TAG="${{ github.event.inputs.version || github.ref_name }}"
echo "VERSION=${TAG#v}" >> $GITHUB_ENV

- name: Validate package
uses: hapakaien/archlinux-package-action@v2
with:
pkgver: ${{ steps.version.outputs.version }}
pkgver: ${{ env.VERSION }}
updpkgsums: true
srcinfo: true

Expand Down Expand Up @@ -147,19 +166,23 @@ jobs:
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Get version
id: version
run: echo "::set-output name=version::$(jq -r .version package.json)"
# NOTE@jsjoeio - we do this so we can strip out the v
# i.e. v4.9.1 -> 4.9.1
- name: Get and set VERSION
run: |
TAG="${{ github.event.inputs.version || github.ref_name }}"
echo "VERSION=${TAG#v}" >> $GITHUB_ENV

- name: Download release artifacts
uses: robinraju/[email protected]
with:
repository: "coder/code-server"
tag: v${{ steps.version.outputs.version }}
tag: v${{ env.VERSION }}
fileName: "*.deb"
out-file-path: "release-packages"

- name: Publish to Docker
run: yarn publish:docker
env:
VERSION: ${{ env.VERSION }}
GITHUB_TOKEN: ${{ github.token }}
117 changes: 89 additions & 28 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@ name: Draft release

on:
workflow_dispatch:
inputs:
version:
description: The version to publish (include "v", i.e. "v4.9.1").
type: string
required: true

permissions:
contents: write # For creating releases.
Expand All @@ -21,6 +26,7 @@ jobs:
name: x86-64 Linux build
runs-on: ubuntu-latest
timeout-minutes: 15
needs: npm-version
container: "centos:7"
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
Expand Down Expand Up @@ -51,15 +57,10 @@ jobs:
- name: Install yarn
run: npm install -g yarn

- name: Download artifacts
uses: dawidd6/action-download-artifact@v2
id: download
- name: Download npm package
uses: actions/download-artifact@v3
with:
branch: ${{ github.ref }}
workflow: build.yaml
workflow_conclusion: completed
check_artifacts: true
name: npm-package
name: npm-release-package

- name: Decompress npm package
run: tar -xzf package.tar.gz
Expand Down Expand Up @@ -91,7 +92,16 @@ jobs:
token: ${{ secrets.CODECOV_TOKEN }}
if: success()

# NOTE@jsjoeio - we do this so we can strip out the v
# i.e. v4.9.1 -> 4.9.1
- name: Get and set VERSION
run: |
TAG="${{ inputs.version || github.ref_name }}"
echo "VERSION=${TAG#v}" >> $GITHUB_ENV

- name: Build packages with nfpm
env:
VERSION: ${{ env.VERSION }}
run: yarn package

- uses: softprops/action-gh-release@v1
Expand Down Expand Up @@ -123,6 +133,7 @@ jobs:
name: Linux cross-compile builds
runs-on: ubuntu-18.04
timeout-minutes: 15
needs: npm-version
strategy:
matrix:
include:
Expand Down Expand Up @@ -159,15 +170,10 @@ jobs:
env:
PACKAGE: ${{ format('g++-{0}', matrix.prefix) }}

- name: Download artifacts
uses: dawidd6/action-download-artifact@v2
id: download
- name: Download npm package
uses: actions/download-artifact@v3
with:
branch: ${{ github.ref }}
workflow: build.yaml
workflow_conclusion: completed
check_artifacts: true
name: npm-package
name: npm-release-package

- name: Decompress npm package
run: tar -xzf package.tar.gz
Expand All @@ -181,7 +187,16 @@ jobs:
tar -xf node-${NODE_VERSION}-linux-${NPM_CONFIG_ARCH}.tar.xz node-${NODE_VERSION}-linux-${NPM_CONFIG_ARCH}/bin/node --strip-components=2
mv ./node ./release-standalone/lib/node

# NOTE@jsjoeio - we do this so we can strip out the v
# i.e. v4.9.1 -> 4.9.1
- name: Get and set VERSION
run: |
TAG="${{ inputs.version || github.ref_name }}"
echo "VERSION=${TAG#v}" >> $GITHUB_ENV

- name: Build packages with nfpm
env:
VERSION: ${{ env.VERSION }}
run: yarn package ${NPM_CONFIG_ARCH}

- uses: softprops/action-gh-release@v1
Expand All @@ -194,6 +209,7 @@ jobs:
name: x86-64 macOS build
runs-on: macos-latest
timeout-minutes: 15
needs: npm-version
steps:
- name: Checkout repo
uses: actions/checkout@v3
Expand All @@ -209,15 +225,10 @@ jobs:
curl -sSfL https://github.com/goreleaser/nfpm/releases/download/v2.3.1/nfpm_2.3.1_`uname -s`_`uname -m`.tar.gz | tar -C ~/.local/bin -zxv nfpm
echo "$HOME/.local/bin" >> $GITHUB_PATH

- name: Download artifacts
uses: dawidd6/action-download-artifact@v2
id: download
- name: Download npm package
uses: actions/download-artifact@v3
with:
branch: ${{ github.ref }}
workflow: build.yaml
workflow_conclusion: completed
check_artifacts: true
name: npm-package
name: npm-release-package

- name: Decompress npm package
run: tar -xzf package.tar.gz
Expand All @@ -241,7 +252,16 @@ jobs:
- name: Run native module tests on standalone release
run: yarn test:native

# NOTE@jsjoeio - we do this so we can strip out the v
# i.e. v4.9.1 -> 4.9.1
- name: Get and set VERSION
run: |
TAG="${{ inputs.version || github.ref_name }}"
echo "VERSION=${TAG#v}" >> $GITHUB_ENV

- name: Build packages with nfpm
env:
VERSION: ${{ env.VERSION }}
run: yarn package

- uses: softprops/action-gh-release@v1
Expand All @@ -254,6 +274,23 @@ jobs:
name: Upload npm package
runs-on: ubuntu-latest
timeout-minutes: 15
needs: npm-version
steps:
- name: Download npm package
uses: actions/download-artifact@v3
with:
name: npm-release-package

- uses: softprops/action-gh-release@v1
with:
draft: true
discussion_category_name: "📣 Announcements"
files: ./package.tar.gz

npm-version:
name: Modify package.json version
runs-on: ubuntu-latest
timeout-minutes: 15
steps:
- name: Download artifacts
uses: dawidd6/action-download-artifact@v2
Expand All @@ -265,8 +302,32 @@ jobs:
check_artifacts: true
name: npm-package

- uses: softprops/action-gh-release@v1
- name: Decompress npm package
run: tar -xzf package.tar.gz

# NOTE@jsjoeio - we do this so we can strip out the v
# i.e. v4.9.1 -> 4.9.1
- name: Get and set VERSION
run: |
TAG="${{ inputs.version || github.ref_name }}"
echo "VERSION=${TAG#v}" >> $GITHUB_ENV

- name: Modify version
env:
VERSION: ${{ env.VERSION )}}
run: |
echo "Updating version in root package.json"
npm version --prefix release "$VERSION"

echo "Updating version in lib/vscode/product.json"
tmp=$(mktemp)
jq '.codeServerVersion = "$VERSION"' release/lib/vscode/product.json > "$tmp" && mv "$tmp" release/lib/vscode/product.json

- name: Compress release package
run: tar -czf package.tar.gz release

- name: Upload npm package artifact
uses: actions/upload-artifact@v3
with:
draft: true
discussion_category_name: "📣 Announcements"
files: ./package.tar.gz
name: npm-release-package
path: ./package.tar.gz
2 changes: 1 addition & 1 deletion ci/build/nfpm.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ platform: "linux"
version: "v${VERSION}"
section: "devel"
priority: "optional"
maintainer: "Anmol Sethi <[email protected]>"
maintainer: "Joe Previte <[email protected]>"
description: |
Run VS Code in the browser.
vendor: "Coder"
Expand Down
Loading