fix: Latest revisions final #20
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Liman Webpage Build Pipeline | |
on: [push] | |
jobs: | |
build: | |
runs-on: ubuntu-20.04 | |
steps: | |
- name: Install checkout | |
uses: actions/checkout@v2 | |
- name: Install node | |
uses: actions/setup-node@v2 | |
with: | |
node-version: 20 | |
- name: Cache dependencies | |
uses: actions/cache@v2 | |
with: | |
path: ~/.npm | |
key: npm-${{ hashFiles('package-lock.json') }} | |
restore-keys: npm- | |
- name: Cache next build | |
uses: actions/cache@v3 | |
with: | |
path: | | |
~/.npm | |
${{ github.workspace }}/.next/cache | |
key: ${{ runner.os }}-nextjs-${{ hashFiles('**/package-lock.json') }}-${{ hashFiles('**/*.[jt]s', '**/*.[jt]sx') }} | |
restore-keys: | | |
${{ runner.os }}-nextjs-${{ hashFiles('**/package-lock.json') }}- | |
- name: Build Next application | |
run: | | |
npm ci --ignore-build | |
npm install --cpu=x64 --os=linux --libc=musl sharp | |
npm rebuild --cpu=x64 --os=linux --libc=musl sharp | |
npm run build | |
[ "$GITHUB_REF" == "refs/heads/master" ] && PRERELEASE=false || PRERELEASE=true | |
echo "PRERELEASE=$(echo $PRERELEASE)" >> $GITHUB_ENV | |
echo "UI_BRANCH=${GITHUB_REF#refs/heads/}" >> $GITHUB_ENV | |
- name: Move Next standalone files and build package | |
run: | | |
cp -r node_modules/\@img .next/standalone/node_modules | |
cp -r public/ .next/standalone/ | |
cp -r .next/static .next/standalone/.next/ | |
TMP_DIR=/tmp/liman-website | |
DEBIAN_PATH=$TMP_DIR/DEBIAN | |
SERVER_BIN_PATH=$TMP_DIR/liman/website | |
rm -rf $TMP_DIR | |
mkdir $TMP_DIR | |
mkdir $DEBIAN_PATH | |
mkdir -p $SERVER_BIN_PATH | |
cp ./build/debian/control $DEBIAN_PATH/control | |
sed -i s/%VERSION%/${{ github.run_number }}/g $DEBIAN_PATH/control | |
cat $DEBIAN_PATH/control | |
cp ./build/debian/postinst $DEBIAN_PATH/postinst | |
chmod 775 $DEBIAN_PATH/postinst | |
mv .next/standalone/* $SERVER_BIN_PATH >/dev/null | |
mv .next/standalone/.next $SERVER_BIN_PATH >/dev/null | |
dpkg-deb --build $TMP_DIR | |
mv /tmp/liman-website.deb /tmp/liman-website-${{ github.run_number }}.deb | |
rm -rf $DEBIAN_PATH | |
sed -i s/%VERSION%/${{ github.run_number }}/g build/rhel/website.spec | |
rpmbuild -ba build/rhel/website.spec --define "_app_dir $TMP_DIR" --define "_rpmdir /tmp" --define "_rpmfilename liman-website-${{ github.run_number }}.rpm" | |
- name: Release 🚀 | |
id: create_release | |
uses: softprops/action-gh-release@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.TOKEN }} | |
with: | |
files: | | |
/tmp/liman-website-${{ github.run_number }}.deb | |
/tmp/liman-website-${{ github.run_number }}.rpm | |
name: "Release ${{ env.UI_BRANCH }} ${{ github.run_number }}" | |
tag_name: "release.${{ env.UI_BRANCH }}.${{ github.run_number }}" | |
prerelease: ${{ env.PRERELEASE }} |