Skip to content

Commit 837bf32

Browse files
committed
build: add github action for dev release
1 parent 8050793 commit 837bf32

8 files changed

Lines changed: 550 additions & 289 deletions

File tree

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
name: extension-dev-release
2+
run-name: ${{ github.actor }} extension dev build
3+
4+
permissions:
5+
contents: write
6+
7+
on:
8+
workflow_dispatch:
9+
push:
10+
branches: [dev]
11+
paths:
12+
- "apps/extension/**"
13+
- "libs/analysis/**"
14+
15+
jobs:
16+
prepare:
17+
runs-on: ubuntu-latest
18+
outputs:
19+
dev-version: ${{ steps.gen.outputs.DEV_VERSION }}
20+
steps:
21+
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
22+
with:
23+
fetch-depth: 0
24+
25+
- id: gen
26+
run: |
27+
dev_version=$(bash scripts/dev-version.sh apps/extension/package.json)
28+
echo "DEV_VERSION=$dev_version" >> "$GITHUB_ENV"
29+
echo "DEV_VERSION=$dev_version" >> "$GITHUB_OUTPUT"
30+
31+
build:
32+
needs: prepare
33+
uses: ./.github/workflows/reusable/extension-build.yml
34+
with:
35+
version: ${{ needs.prepare.outputs.dev-version }}
36+
prerelease: true
37+
tag-name: dev-extension-${{ github.run_number }}
38+
secrets: inherit
39+
40+
cleanup:
41+
needs: build
42+
uses: ./.github/workflows/reusable/dev-release-cleanup.yml
43+
with:
44+
tag-prefix: dev-extension-
45+
secrets: inherit

.github/workflows/extension-release.yml

Lines changed: 12 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -15,52 +15,20 @@ on:
1515
tags:
1616
- "@job-hunting/extension@*"
1717

18-
env:
19-
ROOT_DIR: apps/extension/
20-
2118
jobs:
22-
release:
19+
prepare:
2320
runs-on: ubuntu-latest
21+
outputs:
22+
version: ${{ steps.set-version.outputs.VERSION }}
2423
steps:
25-
- name: Checkout
26-
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
27-
with:
28-
fetch-depth: 1
29-
3024
- name: Set VERSION
31-
run: |
32-
echo "VERSION=${GITHUB_REF_NAME#@job-hunting/extension@}" >> $GITHUB_ENV
33-
34-
- name: Install Nix
35-
uses: DeterminateSystems/nix-installer-action@e50d5f73bfe71c2dd0aa4218de8f4afa59f8f81d
36-
with:
37-
extra-conf: |
38-
accept-flake-config = true
39-
40-
- name: Cache Nix store
41-
uses: DeterminateSystems/magic-nix-cache-action@6221693898146dc97e38ad0e013488a16477a4c4
25+
id: set-version
26+
run: echo "VERSION=${GITHUB_REF_NAME#@job-hunting/extension@}" >> "$GITHUB_OUTPUT"
4227

43-
- name: Build & zip
44-
run: |
45-
nix develop --command moon run extension:zip
46-
nix develop --command moon run extension:zip-firefox
47-
48-
- name: Rename zips
49-
run: |
50-
mv ${{ env.ROOT_DIR }}.output/*-chrome.zip ${{ env.ROOT_DIR }}.output/job-hunting-extension-chrome-${{ env.VERSION }}.zip
51-
mv ${{ env.ROOT_DIR }}.output/*-firefox.zip ${{ env.ROOT_DIR }}.output/job-hunting-extension-firefox-${{ env.VERSION }}.zip
52-
53-
- uses: ./.github/actions/extract-changelog
54-
with:
55-
changelog-path: ${{ env.ROOT_DIR }}CHANGELOG.md
56-
output-path: /tmp/CHANGELOG.txt
57-
58-
- name: Create Release
59-
if: inputs.dry-run != true
60-
uses: softprops/action-gh-release@c95fe1489396fe8a9eb87c0abf8aa5b2ef267fda
61-
with:
62-
body_path: /tmp/CHANGELOG.txt
63-
make_latest: true
64-
files: |
65-
${{ env.ROOT_DIR }}.output/job-hunting-extension-chrome-${{ env.VERSION }}.zip
66-
${{ env.ROOT_DIR }}.output/job-hunting-extension-firefox-${{ env.VERSION }}.zip
28+
release:
29+
needs: prepare
30+
uses: ./.github/workflows/reusable/extension-build.yml
31+
with:
32+
version: ${{ needs.prepare.outputs.version }}
33+
dry-run: ${{ inputs.dry-run || false }}
34+
secrets: inherit
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
name: dev-release-cleanup
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
tag-prefix:
7+
required: true
8+
type: string
9+
description: "Tag prefix to clean (e.g. dev-server-, dev-extension-)"
10+
keep:
11+
required: false
12+
type: number
13+
default: 5
14+
description: "Number of latest releases to keep"
15+
16+
env:
17+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
18+
19+
jobs:
20+
cleanup:
21+
runs-on: ubuntu-latest
22+
steps:
23+
- run: |
24+
KEEP=${{ inputs.keep }}
25+
TAG_PREFIX="${{ inputs.tag-prefix }}"
26+
gh api --paginate "/repos/${GITHUB_REPOSITORY}/git/refs/tags" \
27+
--jq '.[].ref' | grep "^refs/tags/${TAG_PREFIX}" | sort -V | head -n -${KEEP} | while read ref; do
28+
tag="${ref#refs/tags/}"
29+
echo "Cleaning: $tag"
30+
gh release delete "$tag" --yes || true
31+
gh api -X DELETE "/repos/${GITHUB_REPOSITORY}/git/refs/${ref#refs/}" || true
32+
done
Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
name: extension-build
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
version:
7+
required: true
8+
type: string
9+
description: "Version string for artifact and release names"
10+
prerelease:
11+
required: false
12+
type: boolean
13+
default: false
14+
description: "Create a GitHub Pre-release instead of Release"
15+
dry-run:
16+
required: false
17+
type: boolean
18+
default: false
19+
description: "Skip GitHub release"
20+
tag-name:
21+
required: false
22+
type: string
23+
default: ""
24+
description: "Git tag for the release (defaults to GITHUB_REF_NAME)"
25+
26+
env:
27+
ROOT_DIR: apps/extension/
28+
29+
jobs:
30+
release:
31+
runs-on: ubuntu-latest
32+
steps:
33+
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
34+
with:
35+
fetch-depth: 1
36+
37+
- name: Install Nix
38+
uses: DeterminateSystems/nix-installer-action@e50d5f73bfe71c2dd0aa4218de8f4afa59f8f81d
39+
with:
40+
extra-conf: |
41+
accept-flake-config = true
42+
43+
- name: Cache Nix store
44+
uses: DeterminateSystems/magic-nix-cache-action@6221693898146dc97e38ad0e013488a16477a4c4
45+
46+
- name: Build & zip
47+
run: |
48+
nix develop --command moon run extension:zip
49+
nix develop --command moon run extension:zip-firefox
50+
51+
- name: Rename zips
52+
run: |
53+
mv ${{ env.ROOT_DIR }}.output/*-chrome.zip ${{ env.ROOT_DIR }}.output/job-hunting-extension-chrome-${{ inputs.version }}.zip
54+
mv ${{ env.ROOT_DIR }}.output/*-firefox.zip ${{ env.ROOT_DIR }}.output/job-hunting-extension-firefox-${{ inputs.version }}.zip
55+
56+
- name: Upload artifacts
57+
uses: actions/upload-artifact@4cec3d8aa04e39d1a68397de0c4cd6fb9dce8ec1
58+
with:
59+
name: extension-${{ inputs.version }}
60+
path: |
61+
${{ env.ROOT_DIR }}.output/job-hunting-extension-chrome-${{ inputs.version }}.zip
62+
${{ env.ROOT_DIR }}.output/job-hunting-extension-firefox-${{ inputs.version }}.zip
63+
64+
- uses: ./.github/actions/extract-changelog
65+
if: ${{ !inputs.prerelease }}
66+
with:
67+
changelog-path: ${{ env.ROOT_DIR }}CHANGELOG.md
68+
output-path: /tmp/RELEASE_BODY.md
69+
70+
- name: Prepare generic body
71+
if: ${{ inputs.prerelease }}
72+
run: |
73+
{
74+
echo "Dev build from \`${GITHUB_SHA:0:7}\`"
75+
echo ""
76+
echo "Run number: ${GITHUB_RUN_NUMBER}"
77+
echo "Date: $(date -u +%Y%m%d)"
78+
echo "Version: ${{ inputs.version }}"
79+
} > /tmp/RELEASE_BODY.md
80+
81+
- name: Create Release
82+
if: ${{ !inputs.dry-run }}
83+
uses: softprops/action-gh-release@c95fe1489396fe8a9eb87c0abf8aa5b2ef267fda
84+
with:
85+
body_path: /tmp/RELEASE_BODY.md
86+
prerelease: ${{ inputs.prerelease }}
87+
make_latest: ${{ !inputs.prerelease }}
88+
tag_name: ${{ inputs.tag-name || github.ref_name }}
89+
name: Extension ${{ inputs.version }}
90+
files: |
91+
${{ env.ROOT_DIR }}.output/job-hunting-extension-chrome-${{ inputs.version }}.zip
92+
${{ env.ROOT_DIR }}.output/job-hunting-extension-firefox-${{ inputs.version }}.zip
93+
94+

0 commit comments

Comments
 (0)