From c1635a47514808bd5d600b99437b9039aea96c49 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?TED=20Vortex=20=28Teodor-Eugen=20Du=C8=9Bulescu=29?= <237133+0-vortex@users.noreply.github.com> Date: Tue, 3 Aug 2021 22:50:34 +0200 Subject: [PATCH] feat: add release workflow (#1) * feat: add release workflow * fix: temporary remove missing linter function * docs: update broken badge links --- .github/workflows/development.yml | 29 ----- .github/workflows/release.yml | 174 ++++++++++++++++++++++++++++++ README.md | 6 +- 3 files changed, 177 insertions(+), 32 deletions(-) create mode 100644 .github/workflows/release.yml diff --git a/.github/workflows/development.yml b/.github/workflows/development.yml index eb72a98..15a31f6 100644 --- a/.github/workflows/development.yml +++ b/.github/workflows/development.yml @@ -32,32 +32,3 @@ jobs: - name: "🚀 static app" run: npm run build - - lint: - name: Code standards - runs-on: ubuntu-latest - steps: - - name: "☁️ checkout repository" - uses: actions/checkout@v2 - - - name: "🔧 setup node" - uses: actions/setup-node@v2.1.5 - with: - node-version: 16 - - - name: "🔧 setup cache" - uses: actions/cache@v2 - with: - path: ~/.npm - key: ${{ runner.os }}-node-${{ hashFiles('**/npm-shrinkwrap.json') }} - restore-keys: | - ${{ runner.os }}-node- - - - name: "🔧 install npm@7" - run: npm i -g npm@7 - - - name: "📦 install dependencies" - run: npm ci - - - name: "🔍 lint code" - run: npm run lint diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..7008665 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,174 @@ +name: "Release" + +on: + push: + branches: + - main + +jobs: + docker: + name: Build container + runs-on: ubuntu-latest + steps: + - name: "☁️ checkout repository" + uses: actions/checkout@v2 + + - name: "🔧 setup buildx" + uses: docker/setup-buildx-action@v1 + + - name: "📦 docker build" + uses: docker/build-push-action@v2 + with: + context: . + tags: ${{ github.repository }}:latest + outputs: type=docker,dest=/tmp/docker.tar + push: false + + - name: "📂 docker artifacts" + uses: actions/upload-artifact@v2 + with: + name: docker + path: /tmp/docker.tar + + build: + name: Build application + runs-on: ubuntu-latest + steps: + - name: "☁️ checkout repository" + uses: actions/checkout@v2 + + - name: "🔧 setup node" + uses: actions/setup-node@v2.1.5 + with: + node-version: 16 + + - name: "🔧 setup cache" + uses: actions/cache@v2 + with: + path: ~/.npm + key: ${{ runner.os }}-node-${{ hashFiles('**/npm-shrinkwrap.json') }} + restore-keys: | + ${{ runner.os }}-node- + + - name: "🔧 install npm@7" + run: npm i -g npm@7 + + - name: "📦 install dependencies" + run: npm ci + + - name: "🚀 static app" + run: npm run build + + - name: "📂 production artifacts" + uses: actions/upload-artifact@v2 + with: + name: build + path: build + + release: + environment: + name: production + url: https://github.com/${{ github.repository }}/releases/tag/v${{ steps.release.outputs.version }} + name: Semantic release + needs: + - docker + - build + runs-on: ubuntu-latest + steps: + - name: "☁️ checkout repository" + uses: actions/checkout@v2 + with: + fetch-depth: 0 + + - name: "🔧 setup node" + uses: actions/setup-node@v2.1.5 + with: + node-version: 16 + + - name: "🔧 setup cache" + uses: actions/cache@v2 + with: + path: ~/.npm + key: ${{ runner.os }}-node-${{ hashFiles('**/npm-shrinkwrap.json') }} + restore-keys: | + ${{ runner.os }}-node- + + - name: "🔧 install npm@7" + run: npm i -g npm@7 + + - name: "📦 install dependencies" + run: npm ci + + - name: "📂 download docker artifacts" + uses: actions/download-artifact@v2 + with: + name: docker + path: /tmp + + - name: "📦 load tag" + run: | + docker load --input /tmp/docker.tar + docker image ls -a + + - name: "📂 download build artifacts" + uses: actions/download-artifact@v2 + with: + name: build + path: /tmp/build + + - name: "🚀 release" + id: release + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + REPO_OWNER: ${{ github.repository_owner }} + GIT_AUTHOR_NAME: ${{ github.event.commits[0].author.username }} + GIT_AUTHOR_EMAIL: ${{ github.event.commits[0].author.email }} + GIT_COMMITTER_NAME: ${{ secrets.GIT_COMMITTER_NAME }} + GIT_COMMITTER_EMAIL: ${{ secrets.GIT_COMMITTER_EMAIL }} + run: | + cp -R /tmp/build ./build + npx semantic-release + echo "::set-output name=version::$(cat package.json | jq -r '.version')" + + deploy: + name: Deploy to static + needs: + - build + - release + runs-on: ubuntu-latest + steps: + - name: "☁️ checkout repository" + uses: actions/checkout@v2 + + - name: "📂 download artifacts" + uses: actions/download-artifact@v2 + with: + name: build + path: /home/runner/build + + - name: "📂 copy artifacts" + run: | + cp -R /home/runner/build . + ls -lahH ./build + + - name: "🚀 deploy static" + uses: peaceiris/actions-gh-pages@v3 + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + publish_dir: ./build + commit_message: ${{ github.event.head_commit.message }} + enable_jekyll: false + cname: docs.opensauced.pizza + + cleanup: + name: Cleanup actions + needs: + - deploy + runs-on: ubuntu-latest + steps: + - name: "♻️ remove build artifacts" + uses: geekyeggo/delete-artifact@v1 + with: + name: | + build + docker diff --git a/README.md b/README.md index 09dad62..56799f8 100644 --- a/README.md +++ b/README.md @@ -4,9 +4,9 @@ # docs.opensauced.pizza > The path to your next Open Source contribution -[![Commits](https://img.shields.io/github/commit-activity/w/open-sauced/explore.opensauced.pizza?style=flat)](https://github.com/open-sauced/explore.opensauced.pizza/pulse) -[![Issues](https://img.shields.io/github/issues/open-sauced/explore.opensauced.pizza.svg?style=flat)](https://github.com/open-sauced/explore.opensauced.pizza/issues) -[![Releases](https://img.shields.io/github/v/release/open-sauced/explore.opensauced.pizza.svg?style=flat)](https://github.com/open-sauced/explore.opensauced.pizza/releases) +[![Commits](https://img.shields.io/github/commit-activity/w/open-sauced/docs.opensauced.pizza?style=flat)](https://github.com/open-sauced/docs.opensauced.pizza/pulse) +[![Issues](https://img.shields.io/github/issues/open-sauced/docs.opensauced.pizza.svg?style=flat)](https://github.com/open-sauced/docs.opensauced.pizza/issues) +[![Releases](https://img.shields.io/github/v/release/open-sauced/docs.opensauced.pizza.svg?style=flat)](https://github.com/open-sauced/docs.opensauced.pizza/releases) [![Discord](https://img.shields.io/discord/714698561081704529.svg?label=&logo=discord&logoColor=ffffff&color=7389D8&labelColor=6A7EC2)](https://discord.gg/U2peSNf23P) [![Twitter](https://img.shields.io/twitter/follow/saucedopen?label=Follow&style=social)](https://twitter.com/saucedopen)