chore: refactor actions workflows (#222)

This commit is contained in:
Pascal Jufer 2022-12-08 17:06:02 +01:00 committed by GitHub
parent d3179c5825
commit 3ea613b934
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 123 additions and 66 deletions

View file

@ -9,23 +9,41 @@ jobs:
build: build:
name: Build name: Build
runs-on: ubuntu-latest runs-on: ubuntu-latest
# Skip job on forks
if: github.repository_owner == 'iconoir-icons'
steps: steps:
- uses: actions/checkout@v2 - name: Checkout repository
- uses: actions/cache@v2 uses: actions/checkout@v3
with:
path: ~/.pnpm-store - name: Setup Node.js
key: ${{ runner.os }}-${{ hashFiles('**/pnpm-lock.yaml') }} uses: actions/setup-node@v3
restore-keys: | with:
${{ runner.os }}- node-version: 16
- uses: actions/setup-node@v2
with: - name: Install pnpm
node-version: '16' uses: pnpm/action-setup@v2
registry-url: 'https://registry.npmjs.org' with:
- uses: pnpm/action-setup@v2.1.0 version: 7
with:
version: 7.8.0 - name: Get pnpm store directory
run_install: true id: pnpm-cache
- run: pnpm run build run: echo "STORE_PATH=$(pnpm store path)" >> $GITHUB_OUTPUT
- uses: stefanzweifel/git-auto-commit-action@v4
with: - name: Setup pnpm cache
commit_message: Update build artifacts uses: actions/cache@v3
with:
path: ${{ steps.pnpm-cache.outputs.STORE_PATH }}
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-store-
- name: Install dependencies
run: pnpm install
- name: Build
run: pnpm run build
- name: Commit changes
uses: stefanzweifel/git-auto-commit-action@v4
with:
commit_message: Update build artifacts

View file

@ -10,46 +10,68 @@ jobs:
name: Release name: Release
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: actions/checkout@v2 - name: Checkout repository
uses: actions/checkout@v3
with: with:
ref: main # We have to checkout main or PNPM fails. Tag should be on main anyway. # We have to checkout main or PNPM fails. Tag should be on main anyway.
- uses: actions/cache@v2 ref: main
- name: Setup Node.js
uses: actions/setup-node@v3
with: with:
path: ~/.pnpm-store node-version: 16
key: ${{ runner.os }}-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-
- uses: actions/setup-node@v2
with:
node-version: '16'
registry-url: 'https://registry.npmjs.org' registry-url: 'https://registry.npmjs.org'
- uses: pnpm/action-setup@v2.1.0
- name: Install pnpm
uses: pnpm/action-setup@v2
with: with:
version: 7.8.0 version: 7
run_install: true
- uses: rhysd/changelog-from-release/action@v2 - name: Get pnpm store directory
id: pnpm-cache
run: echo "STORE_PATH=$(pnpm store path)" >> $GITHUB_OUTPUT
- name: Setup pnpm cache
uses: actions/cache@v3
with:
path: ${{ steps.pnpm-cache.outputs.STORE_PATH }}
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-store-
- name: Install dependencies
run: pnpm install
- uses: rhysd/changelog-from-release/action@v3
with: with:
file: packages/iconoir-flutter/CHANGELOG.md file: packages/iconoir-flutter/CHANGELOG.md
github_token: ${{ secrets.GITHUB_TOKEN }} github_token: ${{ secrets.GITHUB_TOKEN }}
commit: false commit: false
- run: pnpm run build
- run: pnpm run prepublish-all - name: Build
run: pnpm run build
- name: Prepare packages
run: pnpm run prepublish-all
env: env:
TAG_NAME: ${{ github.ref_name }} TAG_NAME: ${{ github.ref_name }}
- uses: stefanzweifel/git-auto-commit-action@v4
- name: Commit release
uses: stefanzweifel/git-auto-commit-action@v4
with: with:
commit_message: Release Version ${{ github.ref_name }} commit_message: Release Version ${{ github.ref_name }}
branch: main branch: main
- run: git -c user.email="actions@github.com" -c user.name="GitHub Actions" tag -fa ${{ github.ref_name }} -m "${{ github.ref_name }}"
- run: git push -f origin ${{ github.ref_name }} - name: Update tag
- run: npm publish --access public run: |
continue-on-error: true git -c user.email="actions@github.com" -c user.name="GitHub Actions" tag -fa ${{ github.ref_name }} -m "${{ github.ref_name }}"
env: git push -f origin ${{ github.ref_name }}
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
- run: pnpm -r publish --filter './packages/**' --access public - name: Publish packages
continue-on-error: true run: pnpm -r publish --access public
env: env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
# - uses: sakebook/actions-flutter-pub-publisher@v1.4.0 # - uses: sakebook/actions-flutter-pub-publisher@v1.4.0
# with: # with:
# credential: ${{ secrets.PUB_CREDENTIAL_JSON }} # credential: ${{ secrets.PUB_CREDENTIAL_JSON }}

View file

@ -17,45 +17,63 @@ on:
jobs: jobs:
build: build:
name: Build
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: actions/checkout@v2 - name: Checkout repository
uses: actions/checkout@v3
- name: Setup Node.js
uses: actions/setup-node@v3
with: with:
ref: main # We have to checkout main or PNPM fails. Tag should be on main anyway. node-version: 16
- uses: actions/cache@v2
- name: Install pnpm
uses: pnpm/action-setup@v2
with: with:
path: ~/.pnpm-store version: 7
key: ${{ runner.os }}-${{ hashFiles('**/pnpm-lock.yaml') }}
- name: Get pnpm store directory
id: pnpm-cache
run: echo "STORE_PATH=$(pnpm store path)" >> $GITHUB_OUTPUT
- name: Setup pnpm cache
uses: actions/cache@v3
with:
path: ${{ steps.pnpm-cache.outputs.STORE_PATH }}
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: | restore-keys: |
${{ runner.os }}- ${{ runner.os }}-pnpm-store-
- uses: actions/setup-node@v2
with: - name: Install dependencies
node-version: '16' run: pnpm install
registry-url: 'https://registry.npmjs.org'
- uses: pnpm/action-setup@v2.1.0 - name: Build packages
with:
version: 7.8.0
run_install: true
- name: Build Packages
run: pnpm run dist run: pnpm run dist
- name: Build
- name: Build website
run: ./node_modules/.bin/next build run: ./node_modules/.bin/next build
working-directory: iconoir.com working-directory: iconoir.com
- name: Export
- name: Export website
run: ./node_modules/.bin/next export run: ./node_modules/.bin/next export
working-directory: iconoir.com working-directory: iconoir.com
- name: Setup Pages
uses: actions/configure-pages@v1 - name: Setup GitHub Pages
uses: actions/configure-pages@v2
- name: Upload artifact - name: Upload artifact
uses: actions/upload-pages-artifact@v1 uses: actions/upload-pages-artifact@v1
with: with:
path: './iconoir.com/out' path: './iconoir.com/out'
deploy: deploy:
name: Deploy
runs-on: ubuntu-latest
needs: build
environment: environment:
name: github-pages name: github-pages
url: ${{ steps.deployment.outputs.page_url }} url: ${{ steps.deployment.outputs.page_url }}
runs-on: ubuntu-latest
needs: build
steps: steps:
- name: Deploy to GitHub Pages - name: Deploy to GitHub Pages
id: deployment id: deployment

View file

@ -1,6 +1,5 @@
{ {
"name": "iconoir.com", "name": "iconoir.com",
"version": "0.1.0",
"private": true, "private": true,
"scripts": { "scripts": {
"dev": "next dev", "dev": "next dev",