-
Notifications
You must be signed in to change notification settings - Fork 0
62 lines (60 loc) · 2.28 KB
/
build.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
name: Build the NPM tarballs
on:
workflow_dispatch:
env:
FILTER_BRANCH_SQUELCH_WARNING: 1
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/[email protected]
with:
fetch-depth: 1
- name: Fetch the packages folder
run: |
git clone --single-branch --branch develop --depth=1 https://github.com/decidim/decidim packages
cd packages
git filter-branch --prune-empty --subdirectory-filter packages HEAD
rm -rf .git
cd ..
- name: Set version
run: echo "PACKAGE_VERSION=$(jq -r '.version' ./packages/all/package.json)" >> $GITHUB_ENV
- name: NPM pack main
run: |
sed -ri 's|file:\.\./([^"]*)|https://github.com/mainio/decidim-npm-builds/raw/main/builds/decidim-\1.tgz|g' packages/*/package.json
rm -rf builds
mkdir builds
for f in packages/*; do
if [ -f "$f/package.json" ]; then
(cd "$f"; npm pack)
mv "$f/decidim-$(basename $f)"* "builds/decidim-$(basename $f).tgz"
fi
done
- name: Commit changes
run: |
git config --global user.name 'Decidim Builds'
git config --global user.email '[email protected]'
git add builds/*
git diff-index --quiet HEAD -- || (git commit -m "New build" && git push)
- name: Checkout version branch
run: |
BRANCH_NAME="version/${PACKAGE_VERSION}"
(git fetch origin "$BRANCH_NAME" && git checkout "$BRANCH_NAME") || git checkout -b "$BRANCH_NAME"
- name: NPM pack version
run: |
sed -ri "s|decidim-npm-builds/raw/main/|decidim-npm-builds/raw/version/${PACKAGE_VERSION}/|g" packages/*/package.json
rm -rf builds
mkdir builds
for f in packages/*; do
if [ -f "$f/package.json" ]; then
(cd "$f"; npm pack)
mv "$f/decidim-$(basename $f)"* "builds/decidim-$(basename $f).tgz"
fi
done
- name: Commit version branch
run: |
git add builds/*
git diff-index --quiet HEAD -- || (git commit -m "New build" && git push origin "version/${PACKAGE_VERSION}")
- name: Remove the packages folder
run: |
rm -rf packages