|
| 1 | +name: Release |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: |
| 6 | + - main |
| 7 | + tags: |
| 8 | + - '!*' |
| 9 | + |
| 10 | +jobs: |
| 11 | + pre-release: |
| 12 | + name: pre-release |
| 13 | + runs-on: ubuntu-latest |
| 14 | + if: "!contains(github.event.head_commit.message, 'skip release') && !contains(github.event.head_commit.message, 'skip ci')" |
| 15 | + steps: |
| 16 | + - name: Checkout code |
| 17 | + uses: actions/checkout@v2 |
| 18 | + with: |
| 19 | + fetch-depth: '0' |
| 20 | + - name: Check code for leaks |
| 21 | + uses: zricethezav/gitleaks-action@master |
| 22 | + - name: Set up Node.js |
| 23 | + uses: actions/setup-node@v2 |
| 24 | + with: |
| 25 | + node-version: 'lts/*' |
| 26 | + cache: 'npm' |
| 27 | + - name: Install dependencies |
| 28 | + run: npm ci |
| 29 | + - name: Check linting |
| 30 | + run: npm run lint |
| 31 | + - name: Check types |
| 32 | + run: npm run typecheck |
| 33 | + - name: Run tests and collect coverage |
| 34 | + run: npm run coverage |
| 35 | + - name: Upload code coverage |
| 36 | + uses: codecov/codecov-action@v2 |
| 37 | + with: |
| 38 | + token: ${{ secrets.CODECOV_TOKEN }} |
| 39 | + directory: coverage |
| 40 | + flags: unittests |
| 41 | + fail_ci_if_error: true |
| 42 | + verbose: true |
| 43 | + |
| 44 | + release: |
| 45 | + name: release |
| 46 | + runs-on: ubuntu-latest |
| 47 | + needs: [ pre-release ] |
| 48 | + if: "!contains(github.event.head_commit.message, 'skip release') && !contains(github.event.head_commit.message, 'skip ci')" |
| 49 | + steps: |
| 50 | + - name: Checkout code |
| 51 | + uses: actions/checkout@v2 |
| 52 | + - name: Set up Node.js |
| 53 | + uses: actions/setup-node@v2 |
| 54 | + with: |
| 55 | + node-version: 'lts/*' |
| 56 | + cache: 'npm' |
| 57 | + registry-url: 'https://registry.npmjs.org' |
| 58 | + - name: Install dependencies |
| 59 | + run: npm ci |
| 60 | + - name: Import OSlash bot's GPG key for signing commits |
| 61 | + id: import-gpg |
| 62 | + uses: crazy-max/ghaction-import-gpg@v4 |
| 63 | + with: |
| 64 | + gpg_private_key: ${{ secrets.OSLASH_BOT_GPG_PRIVATE_KEY }} |
| 65 | + passphrase: ${{ secrets.OSLASH_BOT_GPG_PASSPHRASE }} |
| 66 | + git_config_global: true |
| 67 | + git_user_signingkey: true |
| 68 | + git_commit_gpgsign: true |
| 69 | + - name: Kick off release |
| 70 | + run: npm_config_yes=true npx semantic-release |
| 71 | + env: |
| 72 | + NPM_USERNAME: oslashbot |
| 73 | + NPM_EMAIL: ${{ steps.import-gpg.outputs.email }} |
| 74 | + NPM_TOKEN: ${{ secrets.OSLASH_BOT_NPM_TOKEN }} |
| 75 | + NODE_AUTH_TOKEN: ${{ secrets.OSLASH_BOT_NPM_TOKEN }} |
| 76 | + GITHUB_TOKEN: ${{ secrets.OSLASH_BOT_GITHUB_TOKEN }} |
| 77 | + GIT_AUTHOR_NAME: ${{ steps.import-gpg.outputs.name }} |
| 78 | + GIT_AUTHOR_EMAIL: ${{ steps.import-gpg.outputs.email }} |
| 79 | + GIT_COMMITTER_NAME: ${{ steps.import-gpg.outputs.name }} |
| 80 | + GIT_COMMITTER_EMAIL: ${{ steps.import-gpg.outputs.email }} |
0 commit comments