|
| 1 | +name: Release |
| 2 | +on: |
| 3 | + push: |
| 4 | + branches: |
| 5 | + - main |
| 6 | + pull_request: {} |
| 7 | + |
| 8 | +jobs: |
| 9 | + lint-commits: |
| 10 | + name: Lint PR commits |
| 11 | + runs-on: ubuntu-latest |
| 12 | + if: ${{ github.event_name == 'pull_request' }} |
| 13 | + steps: |
| 14 | + - uses: actions/checkout@v3 |
| 15 | + with: |
| 16 | + fetch-depth: 0 |
| 17 | + - uses: wagoid/commitlint-github-action@v5 |
| 18 | + |
| 19 | + test-release: |
| 20 | + name: Dry-run semantic-release |
| 21 | + runs-on: ubuntu-latest |
| 22 | + if: ${{ github.event_name == 'pull_request' }} |
| 23 | + steps: |
| 24 | + - name: Checkout |
| 25 | + uses: actions/checkout@v3 |
| 26 | + with: |
| 27 | + fetch-depth: 0 |
| 28 | + - name: Checkout branch |
| 29 | + # Pretend to semantic-release that the PR result is eligible for |
| 30 | + # building releases because --dry-run still filters for configured |
| 31 | + # branches. |
| 32 | + run: git checkout -b main |
| 33 | + - name: Setup Node.js |
| 34 | + uses: actions/setup-node@v3 |
| 35 | + with: |
| 36 | + node-version: 18 |
| 37 | + - name: Cache Node packages |
| 38 | + uses: actions/cache@v3 |
| 39 | + with: |
| 40 | + path: node_modules |
| 41 | + key: release-${{ hashFiles('package.json') }}-${{ hashFiles('package-lock.json') }} |
| 42 | + - name: Install dependencies |
| 43 | + run: npm ci |
| 44 | + - name: Dry-run release |
| 45 | + env: |
| 46 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 47 | + # We need to convince semantic-release to not pick up some |
| 48 | + # configuration from the CI environment by removing the variable that |
| 49 | + # is used for CI detection. |
| 50 | + run: unset GITHUB_ACTIONS && npx semantic-release --dry-run --ci false |
| 51 | + |
| 52 | + release: |
| 53 | + name: Run semantic release |
| 54 | + runs-on: ubuntu-latest |
| 55 | + if: ${{ github.ref == 'refs/heads/main' }} |
| 56 | + steps: |
| 57 | + - name: Checkout |
| 58 | + uses: actions/checkout@v3 |
| 59 | + with: |
| 60 | + fetch-depth: 0 |
| 61 | + - name: Setup Node.js |
| 62 | + uses: actions/setup-node@v3 |
| 63 | + with: |
| 64 | + node-version: 18 |
| 65 | + - name: Cache Node packages |
| 66 | + uses: actions/cache@v3 |
| 67 | + with: |
| 68 | + path: node_modules |
| 69 | + key: release-${{ hashFiles('package.json') }}-${{ hashFiles('package-lock.json') }} |
| 70 | + - name: Install dependencies |
| 71 | + run: npm ci |
| 72 | + - name: Release |
| 73 | + env: |
| 74 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 75 | + run: npx semantic-release |
0 commit comments