|
| 1 | +# CI/CD Release Workflow |
| 2 | +name: pipeline |
| 3 | + |
| 4 | +on: |
| 5 | + pull_request: |
| 6 | + branches: |
| 7 | + - 'release-*' |
| 8 | + - 'master' |
| 9 | + tags-ignore: |
| 10 | + - '*' |
| 11 | +env: |
| 12 | + CI: '' |
| 13 | + COMMIT_SHA: ${{ github.event.pull_request.head.sha }} |
| 14 | + PULL_NUMBER: ${{ github.event.pull_request.number }} |
| 15 | + RUN_ID: ${{ github.run_id }} |
| 16 | + FORCE_COLOR: 2 |
| 17 | + |
| 18 | +jobs: |
| 19 | + pipeline: |
| 20 | + name: Node ${{ matrix.node-version }} on ${{ matrix.os }} |
| 21 | + runs-on: ${{ matrix.os }} |
| 22 | + |
| 23 | + strategy: |
| 24 | + fail-fast: false |
| 25 | + matrix: |
| 26 | + node-version: ['16.x'] |
| 27 | + os: ['ubuntu-latest'] |
| 28 | + |
| 29 | + steps: |
| 30 | + - uses: actions/checkout@v3 |
| 31 | + - name: Use Node.js ${{ matrix.node-version }} |
| 32 | + uses: actions/setup-node@v3 |
| 33 | + with: |
| 34 | + node-version: ${{ matrix.node-version }} |
| 35 | + |
| 36 | + - name: Get yarn cache directory path |
| 37 | + id: yarn-cache-dir-path |
| 38 | + run: echo "::set-output name=dir::$(yarn cache dir)" |
| 39 | + |
| 40 | + - uses: actions/cache@v3 |
| 41 | + id: yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`) |
| 42 | + with: |
| 43 | + path: ${{ steps.yarn-cache-dir-path.outputs.dir }} |
| 44 | + key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }} |
| 45 | + restore-keys: | |
| 46 | + ${{ runner.os }}-yarn- |
| 47 | +
|
| 48 | + - name: Install project |
| 49 | + run: yarn --prefer-offline |
| 50 | + id: install |
| 51 | + |
| 52 | + - name: Build project |
| 53 | + run: yarn run build |
| 54 | + id: production |
| 55 | + |
| 56 | + - name: Pack project |
| 57 | + run: npm pack |
| 58 | + id: pack |
| 59 | + |
| 60 | + - name: Set output info |
| 61 | + run: echo "::set-output name=date::$(date +'%Y-%m-%d')" |
| 62 | + |
| 63 | + - name: Create automatic release |
| 64 | + uses: 'marvinpinto/action-automatic-releases@latest' |
| 65 | + if: ${{ github.event_name == 'push'}} |
| 66 | + with: |
| 67 | + repo_token: '${{ secrets.GITHUB_TOKEN }}' |
| 68 | + automatic_release_tag: 'latest' |
| 69 | + prerelease: true |
| 70 | + files: | |
| 71 | + LICENSE.md |
| 72 | + **.tgz |
| 73 | + id: 'automatic_releases' |
| 74 | + |
| 75 | + |
| 76 | + release: |
| 77 | +# if: startsWith(github.ref, 'refs/tags/') |
| 78 | + |
| 79 | + if: ${{ github.event_name == 'create' && github.event.ref_type == 'tag' }} |
| 80 | + |
| 81 | + runs-on: ubuntu-latest |
| 82 | + steps: |
| 83 | + - name: Checkout |
| 84 | + uses: actions/checkout@v3 |
| 85 | + |
| 86 | + - run: echo "Deploying tag ${{ github.ref }}" ; |
| 87 | + - name: "Build Changelog" |
| 88 | + id: github_release |
| 89 | + uses: mikepenz/release-changelog-builder-action@v3 |
| 90 | + with: |
| 91 | + configuration: ".github/workflows/release.json" |
| 92 | + env: |
| 93 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 94 | + |
| 95 | + - name: Create Release |
| 96 | + uses: actions/create-release@v3 |
| 97 | + with: |
| 98 | + tag_name: ${{ github.ref }} |
| 99 | + release_name: ${{ github.ref }} |
| 100 | + body: ${{steps.github_release.outputs.changelog}} |
| 101 | + env: |
| 102 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
0 commit comments