|
| 1 | +name: Release |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + tags: |
| 6 | + - 'v*.*.*' |
| 7 | + workflow_dispatch: |
| 8 | + inputs: |
| 9 | + version: |
| 10 | + description: Semantic version without the v prefix |
| 11 | + required: true |
| 12 | + type: string |
| 13 | + |
| 14 | +permissions: |
| 15 | + contents: write |
| 16 | + |
| 17 | +concurrency: |
| 18 | + group: release-${{ github.ref }} |
| 19 | + cancel-in-progress: false |
| 20 | + |
| 21 | +jobs: |
| 22 | + release: |
| 23 | + name: Verify and publish release |
| 24 | + runs-on: ubuntu-latest |
| 25 | + timeout-minutes: 30 |
| 26 | + steps: |
| 27 | + - name: Checkout |
| 28 | + uses: actions/checkout@v6 |
| 29 | + with: |
| 30 | + fetch-depth: 0 |
| 31 | + - name: Set up Python |
| 32 | + uses: actions/setup-python@v6 |
| 33 | + with: |
| 34 | + python-version: '3.13' |
| 35 | + cache: pip |
| 36 | + - name: Set up Node.js |
| 37 | + uses: actions/setup-node@v6 |
| 38 | + with: |
| 39 | + node-version-file: .nvmrc |
| 40 | + - name: Install Python dependencies |
| 41 | + run: python -m pip install --disable-pip-version-check --upgrade pip -r requirements.txt |
| 42 | + - name: Install frontend dependencies |
| 43 | + run: npm install --no-audit --no-fund |
| 44 | + - name: Resolve release version |
| 45 | + id: version |
| 46 | + shell: bash |
| 47 | + env: |
| 48 | + INPUT_VERSION: ${{ inputs.version }} |
| 49 | + run: | |
| 50 | + if [[ "${GITHUB_REF_TYPE}" == "tag" ]]; then |
| 51 | + VERSION="${GITHUB_REF_NAME#v}" |
| 52 | + else |
| 53 | + VERSION="${INPUT_VERSION}" |
| 54 | + fi |
| 55 | + if [[ ! "${VERSION}" =~ ^[0-9]+\.[0-9]+\.[0-9]+([+-][0-9A-Za-z.-]+)?$ ]]; then |
| 56 | + echo "Invalid semantic version: ${VERSION}" >&2 |
| 57 | + exit 2 |
| 58 | + fi |
| 59 | + echo "version=${VERSION}" >> "${GITHUB_OUTPUT}" |
| 60 | + - name: Build verified release package |
| 61 | + run: python scripts/release.py --version "${{ steps.version.outputs.version }}" |
| 62 | + - name: Upload release package |
| 63 | + uses: actions/upload-artifact@v7 |
| 64 | + with: |
| 65 | + name: ygit-schema-${{ steps.version.outputs.version }} |
| 66 | + path: | |
| 67 | + release/ygit-schema-${{ steps.version.outputs.version }}.zip |
| 68 | + release/ygit-schema-${{ steps.version.outputs.version }}.zip.sha256 |
| 69 | + if-no-files-found: error |
| 70 | + retention-days: 90 |
| 71 | + - name: Publish GitHub release |
| 72 | + if: github.ref_type == 'tag' |
| 73 | + env: |
| 74 | + GH_TOKEN: ${{ github.token }} |
| 75 | + run: | |
| 76 | + gh release create "${GITHUB_REF_NAME}" \ |
| 77 | + "release/ygit-schema-${{ steps.version.outputs.version }}.zip" \ |
| 78 | + "release/ygit-schema-${{ steps.version.outputs.version }}.zip.sha256" \ |
| 79 | + --verify-tag \ |
| 80 | + --generate-notes \ |
| 81 | + --title "YGit Schema ${{ steps.version.outputs.version }}" |
0 commit comments