Skip to content

Commit

Permalink
Merge pull request #1 from decentraland/feat/add-build-system
Browse files Browse the repository at this point in the history
feat: Add Build system
  • Loading branch information
LautaroPetaccio authored Mar 18, 2024
2 parents 3bd74e8 + 6a82fc0 commit 11eda42
Show file tree
Hide file tree
Showing 14 changed files with 269 additions and 56 deletions.
2 changes: 2 additions & 0 deletions .env
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
GATSBY_WEBSITE_VERSION="1.0.0"
ASSET_PREFIX=""
2 changes: 2 additions & 0 deletions .env.production
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
GATSBY_WEBSITE_VERSION="1.0.0"
ASSET_PREFIX="https://cdn.decentraland.org/@dcl/art-week-site/1.0.0"
18 changes: 18 additions & 0 deletions .github/workflows/audit.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: Audit

on: [push, pull_request]

jobs:
audit:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
- name: Use Node.js 16.x
uses: actions/[email protected]
with:
node-version: 16.x
cache: "npm"
- name: Install
run: npm i
- name: Audit signatures
run: npm audit signatures
45 changes: 45 additions & 0 deletions .github/workflows/build-release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: Build and release

on:
push:
branches:
- master
release:
types:
- created

jobs:
build-release:
permissions:
id-token: write
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
- name: Use Node.js 16.x
uses: actions/[email protected]
with:
node-version: 16.x
cache: "npm"
- name: Set package.json version
uses: menduz/oddish-action@master
with:
cwd: ./webapp
deterministic-snapshot: true
only-update-versions: true
- name: Install
run: npm install
- name: Build
env:
NODE_ENV: production
run: npm run build -- --prefix-paths
- name: Publish
uses: menduz/oddish-action@master
with:
cwd: ./public
deterministic-snapshot: true
registry-url: "https://registry.npmjs.org"
access: public
gitlab-token: ${{ secrets.GITLAB_CDN_DEPLOYER_TOKEN }}
gitlab-pipeline-url: ${{ secrets.GITLAB_CDN_DEPLOYER_URL }}
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
37 changes: 0 additions & 37 deletions .github/workflows/release.yml

This file was deleted.

46 changes: 46 additions & 0 deletions .github/workflows/set-rollout-manual.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: Set rollout by path - Manual

on:
workflow_dispatch:
inputs:
packageVersion:
description: "NPM Version of the release (@dcl/art-week-site)"
required: true
default: ""
deploymentEnvironment:
type: "choice"
description: "Deployment environment"
required: true
default: "zone"
options:
- zone
- today
- org
rolloutPercentage:
description: "The percentage for this rollout"
required: true
default: "100"

jobs:
set-manual-by-path-rollout:
runs-on: ubuntu-latest
steps:
- uses: hmarr/debug-action@v2
- name: Set Rollout
uses: decentraland/set-rollout-action@v2
with:
token: ${{ secrets.GITHUB_TOKEN }}

# Repo deployment info
ref: ${{ github.event.ref }}
sha: ${{ github.sha }}

# CDN information
packageName: "@dcl/art-week-site"
packageVersion: ${{ github.event.inputs.packageVersion }}

# Rollout information
deploymentPath: "artweek"
deploymentEnvironment: ${{ github.event.inputs.deploymentEnvironment }}
deploymentName: "_site"
percentage: ${{ github.event.inputs.rolloutPercentage }}
50 changes: 50 additions & 0 deletions .github/workflows/set-rollout.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
name: Set rollout by path

on: [deployment_status]

jobs:
set-rollout:
if: ${{ github.event.deployment.task == 'upload-to-cdn' && github.event.deployment_status.state == 'success' }}
runs-on: ubuntu-latest
steps:
- uses: hmarr/debug-action@v2

# Dev
- name: Set Rollout - Development
uses: decentraland/set-rollout-action@v2
with:
token: ${{ secrets.GITHUB_TOKEN }}

# Repo deployment info
ref: ${{ github.event.deployment.ref }}
sha: ${{ github.event.deployment.sha }}

# CDN information
packageName: ${{ github.event.deployment.payload.packageName }}
packageVersion: ${{ github.event.deployment.payload.packageVersion }}

# Rollout information
deploymentPath: "artweek"
deploymentEnvironment: "zone"
deploymentName: "_site"
percentage: 100

# Stg
- name: Set Rollout - Staging
uses: decentraland/set-rollout-action@v2
with:
token: ${{ secrets.GITHUB_TOKEN }}

# Repo deployment info
ref: ${{ github.event.deployment.ref }}
sha: ${{ github.event.deployment.sha }}

# CDN information
packageName: ${{ github.event.deployment.payload.packageName }}
packageVersion: ${{ github.event.deployment.payload.packageVersion }}

# Rollout information
deploymentPath: "artweek"
deploymentEnvironment: "today"
deploymentName: "_site"
percentage: 100
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,6 @@ public
.cache
.DS_Store
yarn.lock
package.lock
package.lock
.env.production
package.json.tmp
4 changes: 1 addition & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
# DCLMF 2023 - Decentraland Music Festival

![festival](./static/logo-metaverse.png)
# DCL Art Week Site - Decentraland Art Week
25 changes: 15 additions & 10 deletions gatsby-config.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
require("dotenv").config({
path: `.env.${process.env.NODE_ENV}`,
});

module.exports = {
siteMetadata: {
siteUrl: "https://www.yourdomain.tld",
title: "metaverse-festival",
siteUrl: "https://decentraland.org/artweek",
title: "Decentraland Art Week",
},
assetPrefix: process.env.ASSET_PREFIX,
plugins: [
"gatsby-plugin-styled-components",
"gatsby-plugin-image",
Expand All @@ -26,18 +31,18 @@ module.exports = {
GitHub: `https://github.com/francisco-zx`,
},
{
Designer: 'GM Studios',
LinkedIn: 'https://github.com/gmstudiosgg'
}
Designer: "GM Studios",
LinkedIn: "https://github.com/gmstudiosgg",
},
],
site: {
'Last update': `2022/10/08`,
"Last update": `2022/10/08`,
Standards: `JavaScript`,
Components: `humans-generator`,
Softwares: `Visual Studio Code, Mac OSX, Adobe Illustrator`
Softwares: `Visual Studio Code, Mac OSX, Adobe Illustrator`,
},
note: `Made in Buenos Aires, Argentina.`
}
}
note: `Made in Buenos Aires, Argentina.`,
},
},
],
};
7 changes: 5 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 13 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
{
"name": "metaverse-festival",
"name": "@dcl/art-week-site",
"version": "1.0.0",
"private": true,
"description": "metaverse-festival",
"author": "Guido La Rosa",
"description": "Art Week",
"author": "Decentraland",
"keywords": [
"gatsby"
],
"scripts": {
"prebuild": "node scripts/prebuild.js",
"postbuild": "node scripts/postbuild.js",
"develop": "gatsby develop --https",
"start": "gatsby develop --https",
"build": "gatsby build",
Expand All @@ -34,5 +36,13 @@
"react-multi-carousel": "^2.8.2",
"react-player": "^2.9.0",
"styled-components": "^5.3.1"
},
"engines": {
"node": "16"
},
"homepage": "https://decentraland.org",
"repository": {
"type": "git",
"url": "https://github.com/decentraland/artweek.git"
}
}
7 changes: 7 additions & 0 deletions scripts/postbuild.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
const fs = require("fs");

const PACKAGE_JSON_PUBLIC_PATH = "./public/package.json";
const PACKAGE_JSON_TEMP_PATH = "./package.json.tmp";

fs.copyFileSync(PACKAGE_JSON_TEMP_PATH, PACKAGE_JSON_PUBLIC_PATH);
fs.unlinkSync(PACKAGE_JSON_TEMP_PATH);
62 changes: 62 additions & 0 deletions scripts/prebuild.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
/* eslint-disable */
const fs = require("fs");
const dotenv = require("dotenv");

dotenv.config();

let ENV_CONTENT = {};

// read files
if (fs.existsSync(".env")) {
Object.assign(ENV_CONTENT, dotenv.parse(fs.readFileSync(".env")));
}
const packageJson = JSON.parse(fs.readFileSync("./package.json").toString());

// set version
ENV_CONTENT["GATSBY_WEBSITE_VERSION"] = packageJson.version;

// set public url
Object.assign(ENV_CONTENT, getPublicUrls());
packageJson.homepage = ENV_CONTENT["ASSET_PREFIX"];
if (packageJson.homepage) {
// github action outputs. Do not touch.
console.log("::set-output name=public_url::" + packageJson.homepage);
console.log(
"::set-output name=public_path::" + new URL(packageJson.homepage).pathname
);
}

// log stuff
console.log("VERSIONS: ", Object.entries(ENV_CONTENT), "\n");

// save files
fs.writeFileSync(
".env.production",
Object.entries(ENV_CONTENT)
.map((e) => e[0] + "=" + JSON.stringify(e[1]))
.join("\n") + "\n"
);
fs.writeFileSync("./package.json.tmp", JSON.stringify(packageJson, null, 2));

// public url logic
function getPublicUrls() {
const isStatic = !!process.env.GEN_STATIC_LOCAL;
const isCI = !!process.env.CI;
const isCDN = !isStatic && isCI;
console.log("is static", isStatic);
console.log("is CI", isCI);
console.log("is CDN", isCDN);
if (isCDN) {
// master/main branch, also releases
const cdnUrl = `https://cdn.decentraland.org/${packageJson.name}/${packageJson.version}`;
console.log(`Using CDN as public url: "${cdnUrl}"`);
return {
ASSET_PREFIX: cdnUrl,
};
}
// localhost
console.log("Using empty pubic url");
return {
ASSET_PREFIX: "",
};
}

0 comments on commit 11eda42

Please sign in to comment.