diff --git a/.github/workflows/ci-cd.yml b/.github/workflows/ci-cd.yml index ae48c53..e6bf70b 100644 --- a/.github/workflows/ci-cd.yml +++ b/.github/workflows/ci-cd.yml @@ -12,7 +12,7 @@ on: branches: - main -permissions: write-all +permissions: read-all jobs: code-quality: diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..85cdfa1 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,63 @@ +name: Create Release + +on: + push: + tags: + - v*.*.* # Triggers the workflow on version tags like v1.0.0 + +permissions: read-all + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v3 + + - name: Set up Python + uses: actions/setup-python@v4 + with: + python-version: 3.10 + + - name: Install Poetry + run: | + curl -sSL https://install.python-poetry.org | python3 - + echo "export PATH=$HOME/.local/bin:$PATH" >> $GITHUB_ENV + + - name: Install dependencies + run: poetry install --no-interaction --no-ansi + + - name: Build the package + run: poetry build + + - name: Extract version + id: get_version + run: echo "VERSION=$(poetry version -s)" >> $GITHUB_ENV + + - name: Create GitHub Release + id: create_release + uses: actions/create-release@v1 + with: + tag_name: ${{ github.ref }} # Use the tag that triggered the workflow + release_name: Release ${{ github.ref }} + draft: false + prerelease: false + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + - name: Upload Wheel Asset + uses: actions/upload-release-asset@v1 + with: + upload_url: ${{ steps.create_release.outputs.upload_url }} + asset_path: dist/say_hello-${{ env.VERSION }}-py3-none-any.whl + asset_name: say_hello-${{ env.VERSION }}-py3-none-any.whl + asset_content_type: application/zip + + - name: Upload Source Distribution Asset + uses: actions/upload-release-asset@v1 + with: + upload_url: ${{ steps.create_release.outputs.upload_url }} + asset_path: dist/say_hello-${{ env.VERSION }}.tar.gz + asset_name: say_hello-${{ env.VERSION }}.tar.gz + asset_content_type: application/gzip