Skip to content

Commit

Permalink
ci: Clean up CI/CD workflow and use release action
Browse files Browse the repository at this point in the history
PR: #258
  • Loading branch information
btorresgil committed Aug 31, 2020
1 parent d4a9c3f commit 3d5347a
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 45 deletions.
59 changes: 21 additions & 38 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,11 @@ on:
- develop
- beta
- alpha
- '[0-9]+.x'
- '[0-9]+.[0-9]+.x'
pull_request:

jobs:

test:
name: Test
runs-on: ubuntu-latest
Expand All @@ -28,18 +29,18 @@ jobs:

- name: Install Poetry
uses: dschep/install-poetry-action@v1.3
with:
create_virtualenvs: true

- name: Get poetry cache
- name: Get poetry cache directory
id: poetry-cache
run: echo "::set-output name=dir::$(poetry config cache-dir)"

- name: Cache poetry
uses: actions/cache@v1
- name: Cache poetry dependencies
uses: actions/cache@v2
with:
path: ${{ steps.poetry-cache.outputs.dir }}
key: ${{ runner.os }}-poetry-${{ matrix.python-version }}-${{ hashFiles('**/poetry.lock') }}
key:
${{ runner.os }}-poetry-${{ matrix.python-version }}-${{
hashFiles('**/poetry.lock') }}
restore-keys: |
${{ runner.os }}-poetry-${{ matrix.python-version }}-
Expand All @@ -62,14 +63,12 @@ jobs:

- name: Install Poetry
uses: dschep/install-poetry-action@v1.3
with:
create_virtualenvs: true

- name: Get poetry cache
- name: Get poetry cache directory
id: poetry-cache
run: echo "::set-output name=dir::$(poetry config cache-dir)"

- name: Cache poetry
- name: Cache poetry dependencies
uses: actions/cache@v1
with:
path: ${{ steps.poetry-cache.outputs.dir }}
Expand All @@ -85,49 +84,26 @@ jobs:

release:
name: Release
if: github.event_name == 'push' && (github.ref == 'refs/heads/master' || github.ref == 'refs/heads/beta' || github.ref == 'refs/heads/alpha')
if: github.event_name == 'push' && github.ref != 'refs/heads/develop'
needs: [test, format]
runs-on: ubuntu-18.04
steps:
- name: Checkout
uses: actions/checkout@v2

- name: Cache npm modules
uses: actions/cache@v1
with:
path: ~/.npm
key: ${{ runner.os }}-node-global-install
restore-keys: |
${{ runner.os }}-node-
- name: Setup Node.js
uses: actions/setup-node@v1
with:
node-version: 12

- name: Install semantic-release
run: |
npm install -g \
semantic-release@^17.0.4 \
@semantic-release/exec@^5.0.0 \
@semantic-release/git@^9.0.0 \
conventional-changelog-conventionalcommits@^4.2.3
- name: Set up Python 3.7
uses: actions/setup-python@v1
with:
python-version: 3.7

- name: Install Poetry
uses: dschep/install-poetry-action@v1.3
with:
create_virtualenvs: true

- name: Get poetry cache
- name: Get poetry cache directory
id: poetry-cache
run: echo "::set-output name=dir::$(poetry config cache-dir)"

- name: Cache poetry
- name: Cache poetry dependencies
uses: actions/cache@v1
with:
path: ${{ steps.poetry-cache.outputs.dir }}
Expand All @@ -139,7 +115,14 @@ jobs:
run: poetry install

- name: Create release and publish
id: release
uses: cycjimmy/semantic-release-action@v2
with:
semantic_version: 17.1.1
extra_plugins: |
conventional-changelog-conventionalcommits@^4.4.0
@semantic-release/git@^9.0.0
@semantic-release/exec@^5.0.0
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
POETRY_PYPI_TOKEN_PYPI: ${{ secrets.PYPI_TOKEN }}
run: npx semantic-release
9 changes: 2 additions & 7 deletions .releaserc.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
{
"branches": [
"master",
{ "name": "beta", "prerelease": true },
{ "name": "alpha", "prerelease": true }
],
"preset": "conventionalcommits",
"plugins": [
"@semantic-release/commit-analyzer",
"@semantic-release/release-notes-generator",
Expand Down Expand Up @@ -32,6 +28,5 @@
"successComment": ":tada: This ${issue.pull_request ? 'PR is included' : 'issue has been resolved'} in version ${nextRelease.version} :tada:\n\nThe release is available on [PyPI](https://pypi.org/project/pan-os-python/) and [GitHub release](<github_release_url>)\n\n> Posted by [semantic-release](https://github.com/semantic-release/semantic-release) bot"
}
]
],
"preset": "conventionalcommits"
]
}

0 comments on commit 3d5347a

Please sign in to comment.