Skip to content

Commit d3b8be6

Browse files
committed
Move to github release workflow instead
1 parent 893226b commit d3b8be6

File tree

3 files changed

+37
-142
lines changed

3 files changed

+37
-142
lines changed

.github/workflows/main.yml

Lines changed: 35 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
1-
name: Nightly Builds
1+
name: Version-based Release
22

33
on:
4-
schedule:
5-
# * is a special character in YAML so you have to quote this string
6-
- cron: '0 0 * * *'
74
push:
85
branches:
96
- main
@@ -14,79 +11,57 @@ jobs:
1411

1512
outputs:
1613
upload_url: ${{ steps.create_release.outputs.upload_url }}
17-
date: ${{ steps.current_time_underscores.outputs.formattedTime }}
18-
activity_check: ${{ env.GHA_REPO_ALIVE }}
14+
version: ${{ steps.package_version.outputs.version }}
15+
should_release: ${{ steps.check_release.outputs.should_release }}
1916

2017
steps:
21-
- name: Activity check
18+
- uses: actions/checkout@v4
19+
20+
- name: Get package version
21+
id: package_version
22+
run: |
23+
VERSION=$(node -p "require('./package.json').version")
24+
echo "version=$VERSION" >> $GITHUB_OUTPUT
25+
echo "tag=$VERSION" >> $GITHUB_OUTPUT
26+
27+
- name: Check if release exists
28+
id: check_release
2229
run: |
23-
:
24-
# Based off https://github.community/t/trigger-workflow-if-there-is-commit-in-last-24-hours/17074/3
25-
curl -sL https://api.github.com/repos/$GITHUB_REPOSITORY/commits | jq -r '[.[]][0]' > $HOME/commit.json
26-
date="$(jq -r '.commit.committer.date' $HOME/commit.json)"
27-
timestamp=$(date --utc -d "$date" +%s)
28-
author="$(jq -r '.commit.committer.name' $HOME/commit.json)"
29-
url="$(jq -r '.html_url' $HOME/commit.json)"
30-
days=$(( ( $(date --utc +%s) - $timestamp ) / 86400 ))
31-
rm -f $HOME/commit.json
32-
echo "Repository activity : $timestamp $author $url"
33-
alive=0
34-
if [ "${{ github.event_name }}" == "repository_dispatch" ]; then
35-
echo "[WARNING] Ignoring activity limits : workflow triggered manually"
36-
alive=1
30+
if gh release view ${{ steps.package_version.outputs.version }} >/dev/null 2>&1; then
31+
echo "Release ${{ steps.package_version.outputs.version }} already exists"
32+
echo "should_release=false" >> $GITHUB_OUTPUT
3733
else
38-
if [ $days -lt 1 ]; then
39-
echo Repository active : $days days
40-
alive=1
41-
else
42-
echo "[WARNING] Repository not updated : event<${{ github.event_name }}> not allowed to modify stale repository"
43-
fi
44-
fi
45-
if [ $alive -eq 1 ]; then
46-
echo ::set-env name=GHA_REPO_ALIVE::true
34+
echo "Release ${{ steps.package_version.outputs.version }} does not exist"
35+
echo "should_release=true" >> $GITHUB_OUTPUT
4736
fi
48-
shell: bash
49-
env:
50-
ACTIONS_ALLOW_UNSECURE_COMMANDS: 'true'
51-
52-
- name: Get current time
53-
uses: 1466587594/get-current-time@v2
54-
id: current_time_dashes
55-
with:
56-
format: YYYY-MM-DD
5737
env:
58-
ACTIONS_ALLOW_UNSECURE_COMMANDS: 'true'
59-
60-
- name: Get current time with underscores
61-
uses: 1466587594/get-current-time@v2
62-
id: current_time_underscores
63-
with:
64-
format: YYYY_MM_DD
65-
env:
66-
ACTIONS_ALLOW_UNSECURE_COMMANDS: 'true'
38+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
6739

6840
- name: Create release
69-
if: env.GHA_REPO_ALIVE == 'true'
41+
if: steps.check_release.outputs.should_release == 'true'
7042
id: create_release
7143
uses: actions/create-release@v1
7244
env:
73-
ACTIONS_ALLOW_UNSECURE_COMMANDS: 'true'
7445
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
7546
with:
76-
tag_name: nightly-${{ steps.current_time_dashes.outputs.formattedTime }}
77-
release_name: Nightly ${{ steps.current_time_dashes.outputs.formattedTime }}
78-
prerelease: true
47+
tag_name: ${{ steps.package_version.outputs.version }}
48+
release_name: Release ${{ steps.package_version.outputs.version }}
49+
prerelease: false
7950

8051
upload-release:
8152
runs-on: ubuntu-latest
8253
needs: create-release
83-
if: needs.create-release.outputs.activity_check == 'true'
54+
if: needs.create-release.outputs.should_release == 'true'
55+
8456
steps:
85-
- uses: actions/checkout@v2
86-
- name: Use Node.js 14.x
87-
uses: actions/setup-node@v1
57+
- uses: actions/checkout@v4
58+
59+
- name: Use Node.js 22
60+
uses: actions/setup-node@v4
8861
with:
89-
node-version: 14.x
62+
node-version: '22'
63+
cache: 'npm'
64+
9065
- run: npm install
9166

9267
- name: Build and Package Release
@@ -99,7 +74,6 @@ jobs:
9974
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
10075
with:
10176
upload_url: ${{ needs.create-release.outputs.upload_url }}
102-
asset_path: ./extension.fplx
103-
asset_name: analytics-ext_nightly_${{ needs.create-release.outputs.date }}.zip
77+
asset_path: ./extension.zip
78+
asset_name: extension.zip
10479
asset_content_type: application/zip
105-

.github/workflows/nexus.yml

Lines changed: 0 additions & 79 deletions
This file was deleted.

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)