File: release.yml

package info (click to toggle)
django-polymorphic 4.10.2-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 2,104 kB
  • sloc: python: 12,304; javascript: 280; makefile: 15
file content (155 lines) | stat: -rw-r--r-- 4,460 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
name: Publish Release

permissions: read-all

concurrency:
  # stop previous release runs if tag is recreated
  group: release-${{ github.ref }}
  cancel-in-progress: true

on:
  push:
    tags:
      - 'v*'  # only publish on version tags (e.g. v1.0.0)

jobs:

  lint:
    if: github.repository == 'jazzband/django-polymorphic'
    name: Lint
    permissions:
      contents: read
      actions: write
    uses: ./.github/workflows/lint.yml
    secrets: inherit

  test:
    if: github.repository == 'jazzband/django-polymorphic'
    name: Test
    permissions:
      contents: read
      actions: write
    uses: ./.github/workflows/test.yml
    secrets: inherit

  build:
    if: github.repository == 'jazzband/django-polymorphic'
    name: Build Package
    runs-on: ubuntu-latest
    permissions:
      contents: read
      actions: write
    outputs:
      PACKAGE_NAME: ${{ steps.set-package.outputs.package_name }}
      RELEASE_VERSION: ${{ steps.set-package.outputs.release_version }}
    steps:
    - uses: actions/checkout@v6
    - name: Set up Python
      uses: actions/setup-python@v6
      id: sp
      with:
        python-version: "3.13"  # for tomlib
    - name: Install uv
      uses: astral-sh/setup-uv@v7
      with:
        enable-cache: true
    - name: Setup Just
      uses: extractions/setup-just@v3
    - name: Install Dependencies
      run: |
        just setup ${{ steps.sp.outputs.python-path }}
        sudo apt-get install -y gettext
    - name: Verify Tag
      run: |
        TAG_NAME=${GITHUB_REF#refs/tags/}
        echo "Verifying tag $TAG_NAME..."
        # if a tag was deleted and recreated we may have the old one cached
        # be sure that we're publishing the current tag!
        git fetch --force origin refs/tags/$TAG_NAME:refs/tags/$TAG_NAME

        # verify signature
        curl -sL https://github.com/${{ github.actor }}.gpg | gpg --import 
        git tag -v "$TAG_NAME"

        # verify version
        RELEASE_VERSION=$(just validate_version $TAG_NAME)

        # export the release version
        echo "RELEASE_VERSION=${RELEASE_VERSION}" >> $GITHUB_ENV 
    - name: Build the binary wheel and a source tarball
      run: just build
    - name: Store the distribution packages
      uses: actions/upload-artifact@v5
      with:
        name: python-package-distributions
        path: dist/
    - name: Set Package Name
      id: set-package
      run:
        PACKAGE_NAME=$(python -c "import tomllib; print(tomllib.load(open('pyproject.toml', 'rb'))['project']['name'])")
        echo "PACKAGE_NAME=${PACKAGE_NAME}" >> $GITHUB_ENV

  publish-to-jazzband:
    name: Publish to Jazzband
    needs:
      - lint
      - test
      - build
    runs-on: ubuntu-latest
    steps:
    - name: Download all the dists
      uses: actions/download-artifact@v6
      with:
        name: python-package-distributions
        path: dist/
    - name: Upload Package to Jazzband
      uses: pypa/gh-action-pypi-publish@release/v1.13
      with:
        user: jazzband
        password: ${{ secrets.JAZZBAND_RELEASE_KEY }}
        attestations: false
        repository-url: https://jazzband.co/projects/django-polymorphic/upload
        verbose: true

  github-release:
    name: Publish GitHub Release
    runs-on: ubuntu-latest
    needs:
      - lint
      - test
      - build
    permissions:
      contents: write  # IMPORTANT: mandatory for making GitHub Releases
      id-token: write  # IMPORTANT: mandatory for sigstore

    steps:
    - name: Download all the dists
      uses: actions/download-artifact@v6
      with:
        name: python-package-distributions
        path: dist/
    - name: Sign the dists with Sigstore
      uses: sigstore/gh-action-sigstore-python@v3.1.0
      with:
        inputs: >-
          ./dist/*.tar.gz
          ./dist/*.whl
    - name: Create GitHub Release
      env:
        GITHUB_TOKEN: ${{ github.token }}
      run: >-
        gh release create
        '${{ github.ref_name }}'
        --repo '${{ github.repository }}'
        --generate-notes
        --prerelease
    - name: Upload artifact signatures to GitHub Release
      env:
        GITHUB_TOKEN: ${{ github.token }}
      # Upload to GitHub Release using the `gh` CLI.
      # `dist/` contains the built packages, and the
      # sigstore-produced signatures and certificates.
      run: >-
        gh release upload
        '${{ github.ref_name }}' dist/**
        --repo '${{ github.repository }}'