From d3fe507002db0f0cb03608b2fe02cdb6cf91fa3e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?nicole=20miko=C5=82ajczyk?= Date: Sun, 22 Mar 2026 16:36:03 +0100 Subject: [PATCH] update actions for releases? MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: nicole mikołajczyk --- .github/workflows/nicolium.yaml | 32 +++++++++++++++++++++++++++++ packages/nicolium/package.json | 2 +- packages/nicolium/src/utils/code.ts | 15 ++++++++------ 3 files changed, 42 insertions(+), 7 deletions(-) diff --git a/.github/workflows/nicolium.yaml b/.github/workflows/nicolium.yaml index 6cd8edf1c..f0b3b4f2a 100644 --- a/.github/workflows/nicolium.yaml +++ b/.github/workflows/nicolium.yaml @@ -3,6 +3,7 @@ name: Nicolium CI on: push: branches: [ "develop", "semistable" ] + tags: [ "v*" ] pull_request: branches: [ "develop" ] @@ -69,7 +70,15 @@ jobs: working-directory: ./packages/nicolium/dist run: zip -r ../nicolium.zip . + - name: Upload release zip artifact + if: startsWith(github.ref, 'refs/tags/') + uses: actions/upload-artifact@v4 + with: + name: nicolium-release-zip + path: packages/nicolium/nicolium.zip + - name: build + if: ${{ !startsWith(github.ref, 'refs/tags/') }} env: NODE_ENV: production working-directory: ./packages/nicolium @@ -79,14 +88,17 @@ jobs: cp nicolium.zip dist/pl-fe.zip - name: Build pl-api documentation + if: ${{ !startsWith(github.ref, 'refs/tags/') }} working-directory: ./packages/pl-api run: npx typedoc - name: Copy pl-api documentation + if: ${{ !startsWith(github.ref, 'refs/tags/') }} working-directory: ./packages/pl-api run: cp docs ../nicolium/dist/pl-api-docs -r - name: Create docs redirect + if: ${{ !startsWith(github.ref, 'refs/tags/') }} working-directory: . run: | mkdir -p ./packages/nicolium/dist/docs @@ -96,11 +108,31 @@ jobs: EOF - name: Upload Github Pages artifact + if: ${{ !startsWith(github.ref, 'refs/tags/') }} uses: actions/upload-pages-artifact@v3 with: name: github-pages path: packages/nicolium/dist + release: + needs: build + if: startsWith(github.ref, 'refs/tags/') + runs-on: ubuntu-latest + permissions: + contents: write + steps: + - name: Download release zip artifact + uses: actions/download-artifact@v4 + with: + name: nicolium-release-zip + path: . + + - name: Upload asset to GitHub Release + uses: softprops/action-gh-release@v2 + with: + files: nicolium.zip + generate_release_notes: true + deploy: needs: build if: github.ref == 'refs/heads/develop' diff --git a/packages/nicolium/package.json b/packages/nicolium/package.json index 57e9e9266..92a56a157 100644 --- a/packages/nicolium/package.json +++ b/packages/nicolium/package.json @@ -1,7 +1,7 @@ { "name": "nicolium", "displayName": "Nicolium", - "version": "0.0.1", + "version": "0.1.0", "description": "Mastodon-compatible social media front-end", "keywords": [ "fediverse", diff --git a/packages/nicolium/src/utils/code.ts b/packages/nicolium/src/utils/code.ts index dc827b595..3909d4ca0 100644 --- a/packages/nicolium/src/utils/code.ts +++ b/packages/nicolium/src/utils/code.ts @@ -3,7 +3,7 @@ import { execSync } from 'node:child_process'; import pkg from '../../package.json'; const code = compileTime(() => { - const { CI_COMMIT_TAG, CI_COMMIT_REF_NAME, CI_COMMIT_SHA } = process.env; + const { GITHUB_REF_NAME, GITHUB_SHA, GITHUB_REF_TYPE } = process.env; const shortRepoName = (url: string): string => new URL(url).pathname.slice(1); const trimHash = (hash: string): string => hash.slice(0, 7); @@ -17,13 +17,16 @@ const code = compileTime(() => { }; const version = (pkg: { version: string }): string => { - // Try to discern from GitLab CI first - if (CI_COMMIT_TAG === `v${pkg.version}` || CI_COMMIT_REF_NAME === 'stable') { + const ciTag = GITHUB_REF_TYPE === 'tag' ? GITHUB_REF_NAME : undefined; + const branch = GITHUB_REF_TYPE === 'branch' ? GITHUB_REF_NAME : undefined; + + // Try to discern from GitHub CI first + if (ciTag === `v${pkg.version}` || branch === 'stable') { return pkg.version; } - if (typeof CI_COMMIT_SHA === 'string') { - return `${pkg.version}-${trimHash(CI_COMMIT_SHA)}`; + if (typeof GITHUB_SHA === 'string') { + return `${pkg.version}-${trimHash(GITHUB_SHA)}`; } // Fall back to git directly @@ -43,7 +46,7 @@ const code = compileTime(() => { repository: shortRepoName(pkg.repository.url), version: version(pkg), homepage: pkg.homepage, - ref: CI_COMMIT_TAG ?? CI_COMMIT_SHA ?? tryGit('git rev-parse HEAD'), + ref: (GITHUB_REF_TYPE === 'tag' ? GITHUB_REF_NAME : GITHUB_SHA) ?? tryGit('git rev-parse HEAD'), }; return code;