From 56a1620d0e4ee8ddc2ff3bcb9b02fa97dd5b77d0 Mon Sep 17 00:00:00 2001 From: Drew Yang Date: Mon, 24 Jun 2024 13:59:32 -0500 Subject: [PATCH] =?UTF-8?q?fix(reusable-workflows):=20=E2=9C=A8=20semantic?= =?UTF-8?q?-release=20available=20|=20updated=20devcontainer=20|=20depreca?= =?UTF-8?q?ted=20old=20devcontainer=20and=20make=20release?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../workflows/devcontainer-build-publish.yaml | 33 +++++++ .github/workflows/devcontainer-build.yaml | 5 +- .github/workflows/devcontainer-publish.yaml | 5 +- .github/workflows/make_github_release.yaml | 5 +- .github/workflows/semantic-release.yaml | 94 +++++++++++++++++++ .vscode/settings.json | 4 +- 6 files changed, 140 insertions(+), 6 deletions(-) create mode 100644 .github/workflows/devcontainer-build-publish.yaml create mode 100644 .github/workflows/semantic-release.yaml diff --git a/.github/workflows/devcontainer-build-publish.yaml b/.github/workflows/devcontainer-build-publish.yaml new file mode 100644 index 0000000..7afc76b --- /dev/null +++ b/.github/workflows/devcontainer-build-publish.yaml @@ -0,0 +1,33 @@ +name: Build and Publish DevContainer Image +on: + workflow_call: + secrets: + DOCKERHUB_USERNAME: + required: true + DOCKERHUB_TOKEN: + required: true +jobs: + devcontainer-build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - name: Install dependencies + run: | + sudo curl https://github.com/mikefarah/yq/releases/download/v4.34.1/yq_linux_amd64\ + -Lo /usr/local/bin/yq + sudo chmod +x /usr/local/bin/yq + yq --version + - name: Determine metadata + run: | + PIP_PACKAGE_NAME=$(ls */version.py | cut -d '/' -f 1) + echo "PIP_PACKAGE_NAME=${PIP_PACKAGE_NAME}" >> $GITHUB_ENV + - name: Login to Docker Hub + uses: docker/login-action@v2 + with: + username: ${{secrets.DOCKERHUB_USERNAME}} + password: ${{secrets.DOCKERHUB_TOKEN}} + - name: Build image + run: | + IMAGE=$(yq eval '.services.app.image' ./.devcontainer/docker-compose.yaml) + docker build -t "${IMAGE}" -f ./.devcontainer/Dockerfile . + docker push "${IMAGE}" diff --git a/.github/workflows/devcontainer-build.yaml b/.github/workflows/devcontainer-build.yaml index 020cf1a..0d0e7f7 100644 --- a/.github/workflows/devcontainer-build.yaml +++ b/.github/workflows/devcontainer-build.yaml @@ -1,10 +1,13 @@ -name: Build DevContainer Image +name: Deprecated:Build DevContainer Image on: workflow_call: jobs: devcontainer-build: runs-on: ubuntu-latest steps: + - name: Deprecation Warning + run: | + echo "This action is deprecated. Please use the 'Build and Publish DevContainer Image' reusable workflow instead." - uses: actions/checkout@v3 - name: Install dependencies run: | diff --git a/.github/workflows/devcontainer-publish.yaml b/.github/workflows/devcontainer-publish.yaml index 07a38f7..b428960 100644 --- a/.github/workflows/devcontainer-publish.yaml +++ b/.github/workflows/devcontainer-publish.yaml @@ -1,4 +1,4 @@ -name: Publish DevContainer Image +name: Deprecated:Publish DevContainer Image on: workflow_call: secrets: @@ -10,6 +10,9 @@ jobs: devcontainer-publish: runs-on: ubuntu-latest steps: + - name: Deprecation Warning + run: | + echo "This action is deprecated. Please use the 'Build and Publish DevContainer Image' reusable workflow instead." - uses: actions/checkout@v3 - name: Install dependencies run: | diff --git a/.github/workflows/make_github_release.yaml b/.github/workflows/make_github_release.yaml index 1811660..252cad5 100644 --- a/.github/workflows/make_github_release.yaml +++ b/.github/workflows/make_github_release.yaml @@ -1,4 +1,4 @@ -name: make_github_release +name: Deprecated:make_github_release on: workflow_call: outputs: @@ -11,6 +11,9 @@ jobs: outputs: gh_release_upload_url: ${{ steps.get_release_upload_url.outputs.upload_url }} steps: + - name: Deprecation Warning + run: | + echo "This action is deprecated. Please use the 'Semantic Release' reusable workflow instead." - uses: actions/checkout@v3 - name: Set up Python uses: actions/setup-python@v4 diff --git a/.github/workflows/semantic-release.yaml b/.github/workflows/semantic-release.yaml new file mode 100644 index 0000000..cc0f1e1 --- /dev/null +++ b/.github/workflows/semantic-release.yaml @@ -0,0 +1,94 @@ +name: semantic-release +on: + workflow_call: + +jobs: + release: + runs-on: ubuntu-latest + concurrency: release + permissions: + id-token: write + contents: write + steps: + - name: Checkout code + uses: actions/checkout@v2 + with: + fetch-depth: 0 + # fixed: https://github.com/python-semantic-release/python-semantic-release/issues/721 + - name: Find version.py + id: find_version_dot_py + run: | + echo "version_dot_py_path=$(find * -name "version.py" | head -n 1)" >> $GITHUB_OUTPUT + - name: Config python-semantic-release + env: + VERSION_DOT_PY_PATH: ${{ steps.find_version_dot_py.outputs.version_dot_py_path }} + run: | + cat < .semantic-release.toml + [tool.semantic_release] + assets = [] + build_command_env = [] + commit_message = "{version}\n\nAutomatically generated by python-semantic-release" + commit_parser = "angular" + logging_use_named_masks = true # + major_on_zero = true + allow_zero_version = true + no_git_verify = false + tag_format = "{version}" # + version_variables = [ + "${VERSION_DOT_PY_PATH}:__version__" # + ] + + [tool.semantic_release.branches.main] + match = "(main|master)" + prerelease_token = "rc" + prerelease = false + + [tool.semantic_release.changelog] + template_dir = "templates" + changelog_file = "CHANGELOG.md" + exclude_commit_patterns = [] + + [tool.semantic_release.changelog.environment] + block_start_string = "{%" + block_end_string = "%}" + variable_start_string = "{{" + variable_end_string = "}}" + comment_start_string = "{#" + comment_end_string = "#}" + trim_blocks = false + lstrip_blocks = false + newline_sequence = "\n" + keep_trailing_newline = false + extensions = [] + autoescape = true + + [tool.semantic_release.commit_author] + env = "GIT_COMMIT_AUTHOR" + default = "semantic-release " + + [tool.semantic_release.commit_parser_options] + allowed_tags = ["build", "chore", "ci", "docs", "feat", "fix", "perf", "style", "refactor", "test"] + minor_tags = ["feat"] + patch_tags = ["fix", "perf"] + default_bump_level = 0 + + [tool.semantic_release.remote] + name = "origin" + type = "github" + ignore_token_for_push = false + insecure = false + + [tool.semantic_release.publish] + dist_glob_patterns = ["dist/*"] + upload_to_vcs_release = true + EOF + + echo "INFO::Semantic release configuration:" + cat .semantic-release.toml + + git config --global --add safe.directory ${PWD} + - name: Python Semantic Release + uses: python-semantic-release/python-semantic-release@master + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + root_options: "-c .semantic-release.toml -v" \ No newline at end of file diff --git a/.vscode/settings.json b/.vscode/settings.json index 2d1707a..7755c31 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,8 +1,6 @@ { "conventionalCommits.scopes": [ - "U24 Element", - "U24 Workflow", "reusable-workflows", - "codebook_docker_template" + "starter-workflows" ] } \ No newline at end of file