-
Notifications
You must be signed in to change notification settings - Fork 3
99 lines (86 loc) · 3.23 KB
/
release.yml
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
96
97
98
99
name: Release Extensions
on:
push:
tags:
- 'v*.*.*'
workflow_dispatch: # This allows manual triggering from GitHub UI
permissions:
contents: write # Required to write contents and create releases
jobs:
build-and-release:
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.x'
- name: Install Dependencies
run: |
sudo apt-get update
sudo apt-get install -y zip
# Step to get the version, or use a default if no tag exists (manual trigger)
- name: Get Version from Tag or Default
id: get_version
run: |
if [[ "${GITHUB_REF}" == refs/tags/* ]]; then
VERSION=${GITHUB_REF#refs/tags/}
echo "VERSION=${VERSION}" >> $GITHUB_ENV
else
echo "No tag found, using default version"
echo "VERSION=dev-version" >> $GITHUB_ENV
fi
- name: Assemble Release Notes
id: release_notes
run: |
VERSION=${{ env.VERSION }}
echo "## Release $VERSION" > release_notes.md
echo "" >> release_notes.md
# Use awk to extract release notes if a valid version is found
if [[ "$VERSION" != "dev-version" ]]; then
# Escape special characters for awk and only extract if it's a tagged release
awk "/^## \\[$VERSION\\]/, /^## \\[/" CHANGELOG.md >> release_notes.md || cat RELEASE.HEAD.md >> release_notes.md
else
echo "Manual run, no release notes extracted from CHANGELOG.md" >> release_notes.md
cat RELEASE.HEAD.md >> release_notes.md
fi
- name: Create GitHub Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ env.VERSION }}
release_name: Release ${{ env.VERSION }}
body_path: release_notes.md
draft: false
prerelease: false
- name: Build Chrome Extension
run: |
chmod +x tools/make-chromium.sh
tools/make-chromium.sh $VERSION
- name: Build Firefox Extension
run: |
chmod +x tools/make-firefox.sh
tools/make-firefox.sh $VERSION
- name: Upload Chrome Extension
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: dist/build/FMHY-SafeGuard_${{ env.VERSION }}.chromium.zip
asset_name: FMHY-SafeGuard_${{ env.VERSION }}.chromium.zip
asset_content_type: application/zip
- name: Upload Firefox Extension
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: dist/build/FMHY-SafeGuard_${{ env.VERSION }}.firefox.xpi
asset_name: FMHY-SafeGuard_${{ env.VERSION }}.firefox.xpi
asset_content_type: application/x-xpinstall