-
Notifications
You must be signed in to change notification settings - Fork 256
95 lines (80 loc) · 2.76 KB
/
release.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
name: Bump Version and Release
on:
workflow_dispatch:
inputs:
version:
description: 'Tag version (e.g., 1.0.0 or v1.0.0)'
required: true
message:
description: 'Tag message'
required: true
jobs:
release:
runs-on: ubuntu-latest
permissions:
contents: write
packages: write
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
token: ${{ secrets.PAT }}
- name: Set up Git
run: |
git config --global user.name 'GitHub Actions[bot]'
git config --global user.email 'github-actions[bot]@users.noreply.github.com'
- name: Determine tag version
id: determine_version
run: |
VERSION="${{ github.event.inputs.version }}"
if [[ $VERSION != v* ]]; then
VERSION="v$VERSION"
fi
VERSION_NUMBER="${VERSION#v}"
echo "VERSION=$VERSION" >> $GITHUB_ENV
echo "VERSION_NUMBER=$VERSION_NUMBER" >> $GITHUB_ENV
- name: Update info.json
run: |
OLD_VERSION=$(grep '"version":' public/info.json | awk -F\" '{print $4}')
sed -i "s/$OLD_VERSION/${{ env.VERSION_NUMBER }}/" public/info.json
- uses: pnpm/action-setup@v4
- uses: actions/setup-node@v4
with:
node-version-file: .node-version
cache: pnpm
- run: pnpm install
- run: pnpm run build
- name: Package plugin
run: |
zip -j -r dist/openai-translator-${{ env.VERSION_NUMBER }}.bobplugin ./dist/*
echo "Packaged file: dist/openai-translator-${{ env.VERSION_NUMBER }}.bobplugin"
- name: Update appcast.json
env:
VERSION_NUMBER: ${{ env.VERSION_NUMBER }}
MESSAGE: ${{ github.event.inputs.message }}
run: |
python3 scripts/update_appcast.py "$VERSION_NUMBER" "$MESSAGE"
- name: Commit files
run: |
git commit -a -m 'chore: update appcast.json and info.json'
- name: Create tag
env:
VERSION: ${{ env.VERSION }}
MESSAGE: ${{ github.event.inputs.message }}
run: |
git tag -a "$VERSION" -m "$MESSAGE"
- name: Push changes
uses: ad-m/github-push-action@master
with:
github_token: ${{ secrets.PAT }}
tags: true
- name: Upload binaries to release
uses: svenstaro/upload-release-action@v2
with:
release_name: ${{ env.VERSION }}
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: dist/openai-translator-${{ env.VERSION_NUMBER }}.bobplugin
asset_name: openai-translator-${{ env.VERSION_NUMBER }}.bobplugin
tag: ${{ env.VERSION }}
overwrite: true
body: ${{ github.event.inputs.message }}