Skip to content

Commit 2e212fa

Browse files
authored
Merge pull request #32 from atlanhq/update_workflows
Update workflows
2 parents 08c02fe + 25d3eaa commit 2e212fa

6 files changed

Lines changed: 153 additions & 2 deletions

File tree

.github/workflows/code-ql.yaml

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
2+
name: "Code Scanning - Action"
3+
4+
on: [push, pull_request, workflow_dispatch]
5+
6+
jobs:
7+
CodeQL-Build:
8+
# CodeQL runs on ubuntu-latest, windows-latest, and macos-latest
9+
runs-on: ubuntu-latest
10+
11+
permissions:
12+
# required for all workflows
13+
security-events: write
14+
15+
# only required for workflows in private repositories
16+
actions: read
17+
contents: read
18+
19+
steps:
20+
- name: Checkout repository
21+
uses: actions/checkout@v3
22+
23+
# Initializes the CodeQL tools for scanning.
24+
- name: Initialize CodeQL
25+
uses: github/codeql-action/init@v2
26+
# Override language selection by uncommenting this and choosing your languages
27+
# with:
28+
# languages: go, javascript, csharp, python, cpp, java, ruby
29+
30+
# Autobuild attempts to build any compiled languages (C/C++, C#, Go, or Java).
31+
# If this step fails, then you should remove it and run the build manually (see below).
32+
- name: Autobuild
33+
uses: github/codeql-action/autobuild@v2
34+
35+
# ℹ️ Command-line programs to run using the OS shell.
36+
# 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun
37+
38+
# ✏️ If the Autobuild fails above, remove it and uncomment the following
39+
# three lines and modify them (or add more) to build your code if your
40+
# project uses a compiled language
41+
42+
#- run: |
43+
# make bootstrap
44+
# make release
45+
46+
- name: Perform CodeQL Analysis
47+
uses: github/codeql-action/analyze@v2

.github/workflows/pytest.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: Python package
22

3-
on: [push]
3+
on: [push, workflow_dispatch]
44

55
jobs:
66
build:
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
# This workflow will upload a Python Package using Twine when a release is created
2+
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python#publishing-to-package-registries
3+
4+
# This workflow uses actions that are not certified by GitHub.
5+
# They are provided by a third-party and are governed by
6+
# separate terms of service, privacy policy, and support
7+
# documentation.
8+
9+
name: Upload Python Package
10+
11+
on:
12+
release:
13+
types: [ published ]
14+
workflow_dispatch:
15+
16+
permissions:
17+
contents: read
18+
19+
jobs:
20+
deploy:
21+
if: "success() && startsWith(github.ref, 'refs/tags/')"
22+
runs-on: ubuntu-latest
23+
24+
steps:
25+
- uses: actions/checkout@v3
26+
- name: Set up Python
27+
uses: actions/setup-python@v3
28+
with:
29+
python-version: '3.9'
30+
- name: Install dependencies
31+
run: |
32+
python -m pip install --upgrade pip
33+
pip install build
34+
- name: check tag
35+
id: check-tag
36+
run: ./tests/check_tag.py
37+
- name: Build package
38+
run: python -m build
39+
- name: Publish package
40+
uses: pypa/gh-action-pypi-publish@27b31702a0e7fc50959f5ad993c78deac1bdfc29
41+
with:
42+
user: __token__
43+
password: ${{ secrets.PYPI_API_TOKEN }}

check_tag.py

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
#!/usr/bin/env/python
2+
# Copyright 2022 Atlan Pte, Ltd
3+
# Copyright [2015-2021] The Apache Software Foundation
4+
#
5+
# Licensed to the Apache Software Foundation (ASF) under one
6+
# or more contributor license agreements. See the NOTICE file
7+
# distributed with this work for additional information
8+
# regarding copyright ownership. The ASF licenses this file
9+
# to you under the Apache License, Version 2.0 (the
10+
# "License"); you may not use this file except in compliance
11+
# with the License. You may obtain a copy of the License at
12+
#
13+
# http://www.apache.org/licenses/LICENSE-2.0
14+
#
15+
# Unless required by applicable law or agreed to in writing, software
16+
# distributed under the License is distributed on an "AS IS" BASIS,
17+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18+
# See the License for the specific language governing permissions and
19+
# limitations under the License.
20+
import io
21+
import os
22+
import re
23+
import sys
24+
25+
26+
def read(file_name):
27+
"""Read a text file and return the content as a string."""
28+
with io.open(
29+
os.path.join(os.path.dirname(__file__), file_name), encoding="utf-8"
30+
) as f:
31+
return f.read()
32+
33+
34+
def main(env_var="GITHUB_REF") -> int:
35+
git_ref = os.getenv(env_var, "none")
36+
tag = re.sub("^refs/tags/v*", "", git_ref.lower())
37+
version = read("version.txt").strip()
38+
if tag == version:
39+
return 0
40+
else:
41+
print(
42+
f"✖ {env_var} env var {git_ref!r} does not match package version: {tag!r} != {version!r}"
43+
)
44+
return 1
45+
46+
47+
if __name__ == "__main__":
48+
sys.exit(main())

setup.py

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,18 +18,30 @@
1818
# See the License for the specific language governing permissions and
1919
# limitations under the License.
2020

21+
import io
22+
import os
23+
2124
from setuptools import find_packages, setup
2225

2326
# External dependencies
2427
requirements = ["requests>=2.24", "pydantic>=1.10.4", "jinja2>=3.1.2"]
2528

29+
30+
def read(file_name):
31+
"""Read a text file and return the content as a string."""
32+
with io.open(
33+
os.path.join(os.path.dirname(__file__), file_name), encoding="utf-8"
34+
) as f:
35+
return f.read()
36+
37+
2638
long_description = ""
2739
with open("README.md", "r") as fh:
2840
long_description = fh.read()
2941

3042
setup(
3143
name="pyatlan",
32-
version="0.0.17",
44+
version=read("version.txt"),
3345
author="Atlan Technologies Pvt Ltd",
3446
author_email="engineering@atlan.com",
3547
description="Atlan Python Client",

version.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
0.0.18

0 commit comments

Comments
 (0)