diff --git a/.github/workflows/auto-semver-actions.yml b/.github/workflows/auto-semver-actions.yml new file mode 100644 index 0000000..4bb760c --- /dev/null +++ b/.github/workflows/auto-semver-actions.yml @@ -0,0 +1,74 @@ +name: auto-semver-actions +on: [push] +env: + GITHUB_URL: 'git@github.com:RightBrain-Networks/auto-semver.git' + GITHUB_KEY: 'rbn-ops github' + + SERVICE: 'auto-semver' + SELF_SEMVER_TAG: "master" +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + with: + fetch-depth: 0 + ref: ${{ env.GITHUB_REF }} + - name: Set up Python 3.7 + uses: actions/setup-python@v1 + with: + python-version: 3.7 + - name: Run Auto-Semver + id: semver + uses: RightBrain-Networks/semver-action@1.0.0 + with: + mode: set + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install -r requirements.txt + - name: build + run: | + python setup.py sdist + - name: test + run: | + python tests.py + working-directory: semver + CheckVersion: + runs-on: ubuntu-latest + needs: build + steps: + - name: Checkout + uses: actions/checkout@v2 + - name: Run Auto-Semver + id: semver + uses: RightBrain-Networks/semver-action@1.0.0 + with: + mode: set + - name: Create Release + uses: actions/create-release@v1 + if: steps['semver']['outputs']['RETURN_STATUS'] == '0' + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + tag_name: ${{ steps.semver.outputs.SEMVER_NEW_VERSION }} + release_name: ${{ steps.semver.outputs.SEMVER_NEW_VERSION }} + body: Version ${{ steps.semver.outputs.SEMVER_NEW_VERSION }} released automatically by [RightBrain-Networks/auto-semver](https://github.com/RightBrain-Networks/auto-semver) + draft: false + prerelease: false + release: + runs-on: ubuntu-latest + needs: [CheckVersion, build] + steps: + - uses: actions/checkout@v2 + - uses: actions-ecosystem/action-get-latest-tag@v1 + id: get-latest-tag + - uses: actions-ecosystem/action-bump-semver@v1 + id: bump-semver + with: + current_version: ${{ steps.get-latest-tag.outputs.tag }} + level: minor + - uses: actions-ecosystem/action-push-tag@v1 + with: + tag: ${{ steps.bump-semver.outputs.new_version }} + message: '${{ steps.bump-semver.outputs.new_version }}: PR #${{ github.event.pull_request.number }} ${{ github.event.pull_request.title }}' diff --git a/semver/tests.py b/semver/tests.py index 63025fa..9603c3e 100644 --- a/semver/tests.py +++ b/semver/tests.py @@ -85,11 +85,6 @@ def test_branch_maven_bad_branch(self): subprocess.call(['git', 'checkout', '-b', 'test/branch']) branch = get_version.get_version(version_format='maven') self.assertEqual(branch, "test/branch") - def test_get_version_run(self): - create_git_environment() - val = subprocess.Popen(['python', '../get_version.py', '-d'], stdout=subprocess.PIPE, - stderr=open(os.devnull, 'wb'), cwd='.').stdout.read().decode('utf-8').rstrip() - self.assertEqual(val, "master") class TestGetTagVersion(unittest.TestCase): @@ -230,6 +225,8 @@ def create_git_environment(): subprocess.call(['rm', '-rf', './.git']) subprocess.call(['git', 'init']) subprocess.call(['touch', 'file.txt']) + subprocess.call(['git', 'config', '--global', 'user.name', 'unit-test']) + subprocess.call(['git', 'config', '--global', 'user.email', 'unit-test@rightbrainnetworks.com']) subprocess.call(['git', 'add', 'file.txt']) subprocess.call(['git', 'commit', '-m', 'file.txt']) subprocess.call(['git', 'remote', 'add', 'origin', os.getcwd()+'/.git']) @@ -243,4 +240,4 @@ def create_git_environment(): with open('.bumpversion.cfg', "w") as config: config.write(config_data) unittest.main() - os.chdir("..") \ No newline at end of file + os.chdir("..")