Skip to content

Commit 5000115

Browse files
committed
fix: added release_override github action to allow creating temporary github release
1 parent a1eda3c commit 5000115

File tree

1 file changed

+87
-0
lines changed

1 file changed

+87
-0
lines changed
Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
# ~~ Generated by projen. To modify, edit .projenrc.ts and run "npx projen".
2+
3+
name: release
4+
on:
5+
push:
6+
branches:
7+
- 2.x
8+
workflow_dispatch: {}
9+
concurrency:
10+
group: ${{ github.workflow }}
11+
cancel-in-progress: false
12+
jobs:
13+
release:
14+
runs-on: ubuntu-latest
15+
permissions:
16+
contents: write
17+
outputs:
18+
latest_commit: ${{ steps.git_remote.outputs.latest_commit }}
19+
tag_exists: ${{ steps.check_tag_exists.outputs.exists }}
20+
env:
21+
CI: "true"
22+
steps:
23+
- name: Checkout
24+
uses: actions/checkout@v4
25+
with:
26+
fetch-depth: 0
27+
- name: Set git identity
28+
run: |-
29+
git config user.name "github-actions"
30+
git config user.email "github-actions@github.com"
31+
- run: pip3 install pipenv
32+
- name: Setup Node.js
33+
uses: actions/setup-node@v4
34+
with:
35+
node-version: lts/*
36+
- name: Install dependencies
37+
run: yarn install --check-files --frozen-lockfile
38+
- name: release:2.x
39+
run: npx projen release:2.x
40+
- name: Check if version has already been tagged
41+
id: check_tag_exists
42+
run: |-
43+
TAG=$(cat dist/releasetag.txt)
44+
([ ! -z "$TAG" ] && git ls-remote -q --exit-code --tags origin $TAG && (echo "exists=true" >> $GITHUB_OUTPUT)) || (echo "exists=false" >> $GITHUB_OUTPUT)
45+
cat $GITHUB_OUTPUT
46+
- name: Check for new commits
47+
id: git_remote
48+
run: |-
49+
echo "latest_commit=$(git ls-remote origin -h ${{ github.ref }} | cut -f1)" >> $GITHUB_OUTPUT
50+
cat $GITHUB_OUTPUT
51+
- name: Backup artifact permissions
52+
if: ${{ steps.git_remote.outputs.latest_commit == github.sha }}
53+
run: cd dist && getfacl -R . > permissions-backup.acl
54+
continue-on-error: true
55+
- name: Upload artifact
56+
if: ${{ steps.git_remote.outputs.latest_commit == github.sha }}
57+
uses: actions/upload-artifact@v4.4.0
58+
with:
59+
name: build-artifact
60+
path: dist
61+
overwrite: true
62+
release_github:
63+
name: Publish to GitHub Releases
64+
needs:
65+
- release
66+
runs-on: ubuntu-latest
67+
permissions:
68+
contents: write
69+
if: needs.release.outputs.tag_exists != 'true' && needs.release.outputs.latest_commit == github.sha
70+
steps:
71+
- uses: actions/setup-node@v4
72+
with:
73+
node-version: lts/*
74+
- name: Download build artifacts
75+
uses: actions/download-artifact@v4
76+
with:
77+
name: build-artifact
78+
path: dist
79+
- name: Restore build artifact permissions
80+
run: cd dist && setfacl --restore=permissions-backup.acl
81+
continue-on-error: true
82+
- name: Release
83+
env:
84+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
85+
GITHUB_REPOSITORY: ${{ github.repository }}
86+
GITHUB_REF: ${{ github.sha }}
87+
run: errout=$(mktemp); gh release create $(cat dist/releasetag.txt) -R $GITHUB_REPOSITORY -F dist/changelog.md -t $(cat dist/releasetag.txt) --target $GITHUB_REF 2> $errout && true; exitcode=$?; if [ $exitcode -ne 0 ] && ! grep -q "Release.tag_name already exists" $errout; then cat $errout; exit $exitcode; fi

0 commit comments

Comments
 (0)