Skip to content
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

chore(ui): support prerelease tag versions in app pipeline #330

Merged
merged 1 commit into from
May 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
50 changes: 37 additions & 13 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,24 +21,41 @@ jobs:
with:
node-version: 16

- name: Get Version
id: get-version
run: |
PACKAGE_VERSION=$(node -p "require('./desktop/package.json').version")
echo "PACKAGE_VERSION=$PACKAGE_VERSION" >> $GITHUB_ENV
echo "package_version=$PACKAGE_VERSION" >> $GITHUB_OUTPUT
echo "TAG_NAME=DevPod-v$PACKAGE_VERSION" >> $GITHUB_ENV
- run: npm install semver

- name: Check Version
- name: Get Version
uses: actions/github-script@v6
id: get-version
with:
script: |
const packageVersion = `${process.env.PACKAGE_VERSION}`
const refName = process.env.GITHUB_REF_NAME
if(refName.split("v")[1] !== packageVersion) {
core.setFailed(`Tag must match version from \`desktop/package.json\`. Ref Name: ${refName}, Package Version: ${packageVersion}`)
const semver = require("semver")
const refName = `${process.env.GITHUB_REF_NAME}`
let version = refName.split("v")[1]
const parsed = semver.parse(version);
const supportedPreleases = [
{ tag: "alpha", number: 1 },
{ tag: "beta", number: 2 },
{ tag: "rc", number: 3 },
];
const maybePrelease = semver.prerelease(version);
const maybeSupported = supportedPreleases.find(
(p) => p.tag === maybePrelease?.[0]
);

// If we have a prelease and it is in the supported range, then we can use it
if (maybePrelease && maybeSupported) {
version = `${parsed.major}.${parsed.minor}.${parsed.patch}-${
maybeSupported.number
}${maybePrelease[1] ?? 0}`;
}

if(maybePrelease && !maybeSupported) {
core.setFailed(`Unsupported prerelease: ${version}`)
}

core.info(`Version: ${version}`)
core.setOutput("version", version)

- name: Get Release
uses: actions/github-script@v6
id: get-release
Expand Down Expand Up @@ -106,10 +123,15 @@ jobs:
run: |
git config --global core.autocrlf false
git config --global core.eol lf

- name: Checkout repository
uses: actions/checkout@v3

- name: Apply Version
if: matrix.settings.cli_only == false
run: yarn version --new-version ${{ needs.create-release.outputs.package_version }} --no-git-tag-version
working-directory: "./desktop"

- name: Setup System Dependencies
if: matrix.settings.host == 'ubuntu-latest' && matrix.settings.cli_only == false
run: |
Expand Down Expand Up @@ -452,6 +474,7 @@ jobs:
core.warning(`Unable to find asset: ${info.originalAssetName}`)
continue
}

const assetID = a.id
// Update the asset name
await github.rest.repos.updateReleaseAsset({
Expand Down Expand Up @@ -489,6 +512,7 @@ jobs:
const latestJSON = JSON.stringify(latest)
const latestDestPath = "desktop/latest.json"
core.info(`Writing latest.json to disk (${latestDestPath}): ${latestJSON}`)

fs.writeFileSync(latestDestPath, latestJSON)

// Attempting to upload a previously released asset results in an error so we need to clean up before
Expand Down
2 changes: 1 addition & 1 deletion desktop/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "devpod",
"private": true,
"version": "0.1.5",
"version": "0.0.0",
"type": "module",
"scripts": {
"dev": "vite",
Expand Down
8 changes: 6 additions & 2 deletions desktop/src-tauri/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,11 @@ fn main() -> anyhow::Result<()> {
action_logs::setup(&app.handle())?;
custom_protocol.setup(app.handle());

let app_handle = app.handle();
check_update(app_handle);
#[cfg(feature = "updater")]
{
let app_handle = app.handle();
check_update(app_handle);
}

let app_handle = app.handle();
tauri::async_runtime::spawn(async move {
Expand Down Expand Up @@ -175,6 +178,7 @@ fn main() -> anyhow::Result<()> {
Ok(())
}

#[cfg(feature = "updater")]
fn check_update(app_handle: AppHandle) {
tauri::async_runtime::spawn(async move {
loop {
Expand Down
7 changes: 7 additions & 0 deletions desktop/src-tauri/tauri-dev.conf.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"tauri": {
"updater": {
"active": false
}
}
}