update actions for releases?
Signed-off-by: nicole mikołajczyk <git@mkljczk.pl>
This commit is contained in:
32
.github/workflows/nicolium.yaml
vendored
32
.github/workflows/nicolium.yaml
vendored
@ -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'
|
||||
|
||||
@ -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",
|
||||
|
||||
@ -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;
|
||||
|
||||
Reference in New Issue
Block a user