update actions for releases?

Signed-off-by: nicole mikołajczyk <git@mkljczk.pl>
This commit is contained in:
nicole mikołajczyk
2026-03-22 16:36:03 +01:00
parent 56c8085898
commit d3fe507002
3 changed files with 42 additions and 7 deletions

View File

@ -3,6 +3,7 @@ name: Nicolium CI
on: on:
push: push:
branches: [ "develop", "semistable" ] branches: [ "develop", "semistable" ]
tags: [ "v*" ]
pull_request: pull_request:
branches: [ "develop" ] branches: [ "develop" ]
@ -69,7 +70,15 @@ jobs:
working-directory: ./packages/nicolium/dist working-directory: ./packages/nicolium/dist
run: zip -r ../nicolium.zip . 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 - name: build
if: ${{ !startsWith(github.ref, 'refs/tags/') }}
env: env:
NODE_ENV: production NODE_ENV: production
working-directory: ./packages/nicolium working-directory: ./packages/nicolium
@ -79,14 +88,17 @@ jobs:
cp nicolium.zip dist/pl-fe.zip cp nicolium.zip dist/pl-fe.zip
- name: Build pl-api documentation - name: Build pl-api documentation
if: ${{ !startsWith(github.ref, 'refs/tags/') }}
working-directory: ./packages/pl-api working-directory: ./packages/pl-api
run: npx typedoc run: npx typedoc
- name: Copy pl-api documentation - name: Copy pl-api documentation
if: ${{ !startsWith(github.ref, 'refs/tags/') }}
working-directory: ./packages/pl-api working-directory: ./packages/pl-api
run: cp docs ../nicolium/dist/pl-api-docs -r run: cp docs ../nicolium/dist/pl-api-docs -r
- name: Create docs redirect - name: Create docs redirect
if: ${{ !startsWith(github.ref, 'refs/tags/') }}
working-directory: . working-directory: .
run: | run: |
mkdir -p ./packages/nicolium/dist/docs mkdir -p ./packages/nicolium/dist/docs
@ -96,11 +108,31 @@ jobs:
EOF EOF
- name: Upload Github Pages artifact - name: Upload Github Pages artifact
if: ${{ !startsWith(github.ref, 'refs/tags/') }}
uses: actions/upload-pages-artifact@v3 uses: actions/upload-pages-artifact@v3
with: with:
name: github-pages name: github-pages
path: packages/nicolium/dist 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: deploy:
needs: build needs: build
if: github.ref == 'refs/heads/develop' if: github.ref == 'refs/heads/develop'

View File

@ -1,7 +1,7 @@
{ {
"name": "nicolium", "name": "nicolium",
"displayName": "Nicolium", "displayName": "Nicolium",
"version": "0.0.1", "version": "0.1.0",
"description": "Mastodon-compatible social media front-end", "description": "Mastodon-compatible social media front-end",
"keywords": [ "keywords": [
"fediverse", "fediverse",

View File

@ -3,7 +3,7 @@ import { execSync } from 'node:child_process';
import pkg from '../../package.json'; import pkg from '../../package.json';
const code = compileTime(() => { 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 shortRepoName = (url: string): string => new URL(url).pathname.slice(1);
const trimHash = (hash: string): string => hash.slice(0, 7); const trimHash = (hash: string): string => hash.slice(0, 7);
@ -17,13 +17,16 @@ const code = compileTime(() => {
}; };
const version = (pkg: { version: string }): string => { const version = (pkg: { version: string }): string => {
// Try to discern from GitLab CI first const ciTag = GITHUB_REF_TYPE === 'tag' ? GITHUB_REF_NAME : undefined;
if (CI_COMMIT_TAG === `v${pkg.version}` || CI_COMMIT_REF_NAME === 'stable') { 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; return pkg.version;
} }
if (typeof CI_COMMIT_SHA === 'string') { if (typeof GITHUB_SHA === 'string') {
return `${pkg.version}-${trimHash(CI_COMMIT_SHA)}`; return `${pkg.version}-${trimHash(GITHUB_SHA)}`;
} }
// Fall back to git directly // Fall back to git directly
@ -43,7 +46,7 @@ const code = compileTime(() => {
repository: shortRepoName(pkg.repository.url), repository: shortRepoName(pkg.repository.url),
version: version(pkg), version: version(pkg),
homepage: pkg.homepage, 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; return code;