[ci] prepare release v6.0.0rc15 #44
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Release | |
| on: | |
| push: | |
| tags: | |
| - v*.*.* | |
| env: | |
| PYTHON_VERSION: "3.11" | |
| PREPARATION_COMMIT: '[ci] prepare release ${{ github.ref_name }}' | |
| jobs: | |
| check-preparation: | |
| name: Check if release is prepared | |
| runs-on: ubuntu-24.04 | |
| outputs: | |
| prepared: ${{ steps.validate.outputs.prepared }} | |
| steps: | |
| - uses: actions/checkout@v6 | |
| - name: Validate commit message | |
| id: validate | |
| run: | | |
| COMMIT_MESSAGE=$(git log -1 --pretty=%B) | |
| echo "Expected: '${{ env.PREPARATION_COMMIT }}'" | |
| echo "Received: '$COMMIT_MESSAGE'" | |
| prepared="false" | |
| if [[ "$COMMIT_MESSAGE" == "${{ env.PREPARATION_COMMIT }}" ]]; then | |
| prepared="true" | |
| fi | |
| echo "prepared=$prepared" >> $GITHUB_OUTPUT | |
| prepare-release: | |
| name: Prepare release | |
| needs: [check-preparation] | |
| if: needs.check-preparation.outputs.prepared == 'false' | |
| runs-on: ubuntu-24.04 | |
| steps: | |
| - name: Generate token for Release Bot | |
| id: generate-token | |
| uses: actions/create-github-app-token@v2 | |
| with: | |
| app-id: ${{ vars.RELEASE_BOT_APP_ID }} | |
| private-key: ${{ secrets.RELEASE_BOT_PRIVATE_KEY }} | |
| - uses: actions/checkout@v6 | |
| with: | |
| fetch-depth: 0 | |
| ref: main | |
| token: ${{ steps.generate-token.outputs.token }} | |
| - name: Configure Git | |
| run: | | |
| git config user.name "github-actions[bot]" | |
| git config user.email "41898282+github-actions[bot]@users.noreply.github.com" | |
| - name: Update CITATION.cff | |
| run: | | |
| VERSION=${GITHUB_REF#refs/tags/v} | |
| DATE=$(date +%Y-%m-%d) | |
| sed -i "s/^version: .*/version: $VERSION/" CITATION.cff | |
| sed -i "s/^date-released: .*/date-released: $DATE/" CITATION.cff | |
| - name: Remove previous tag | |
| run: | | |
| git tag -d ${{ github.ref_name }} | |
| git push origin --delete ${{ github.ref_name }} | |
| - name: Commit and re-tag | |
| run: | | |
| git add CITATION.cff | |
| git commit -m "${{ env.PREPARATION_COMMIT }}" | |
| git push origin main | |
| git tag -a ${{ github.ref_name }} -m "${{ github.ref_name }}" | |
| git push origin ${{ github.ref_name }} | |
| test: | |
| name: Run tests | |
| needs: [check-preparation] | |
| if: needs.check-preparation.outputs.prepared == 'true' | |
| uses: ./.github/workflows/tests.yaml | |
| build: | |
| name: Build package | |
| needs: [check-preparation, test] | |
| if: needs.check-preparation.outputs.prepared == 'true' | |
| runs-on: ubuntu-24.04 | |
| steps: | |
| - uses: actions/checkout@v6 | |
| - uses: astral-sh/setup-uv@v6 | |
| with: | |
| version: "0.9.10" | |
| enable-cache: true | |
| - uses: actions/setup-python@v6 | |
| with: | |
| python-version: ${{ env.PYTHON_VERSION }} | |
| - name: Build package | |
| run: uv build | |
| - uses: actions/upload-artifact@v4 | |
| with: | |
| name: dist | |
| path: dist/ | |
| retention-days: 7 | |
| publish-pypi: | |
| name: Publish to PyPI | |
| needs: [build] | |
| runs-on: ubuntu-24.04 | |
| environment: | |
| name: pypi | |
| url: https://pypi.org/p/flixopt | |
| permissions: | |
| id-token: write | |
| steps: | |
| - uses: actions/download-artifact@v4 | |
| with: | |
| name: dist | |
| path: dist/ | |
| - name: Publish to PyPI | |
| uses: pypa/gh-action-pypi-publish@release/v1 | |
| with: | |
| skip-existing: true | |
| verify-pypi: | |
| name: Verify PyPI installation | |
| needs: [publish-pypi] | |
| runs-on: ubuntu-24.04 | |
| steps: | |
| - uses: astral-sh/setup-uv@v6 | |
| with: | |
| version: "0.9.10" | |
| - uses: actions/setup-python@v6 | |
| with: | |
| python-version: ${{ env.PYTHON_VERSION }} | |
| - name: Verify installation | |
| run: | | |
| VERSION=${GITHUB_REF#refs/tags/v} | |
| for delay in 10 20 40 60 90 120 180 300; do | |
| sleep $delay | |
| echo "Attempting installation (waited ${delay}s)..." | |
| if uv pip install --system --index-url https://pypi.org/simple/ "flixopt==$VERSION" && \ | |
| python -c "from importlib.metadata import version; assert version('flixopt') == '$VERSION'"; then | |
| echo "PyPI installation successful!" | |
| exit 0 | |
| fi | |
| done | |
| echo "Failed to verify PyPI installation" | |
| exit 1 | |
| create-release: | |
| name: Create GitHub release | |
| needs: [verify-pypi] | |
| runs-on: ubuntu-24.04 | |
| permissions: | |
| contents: write | |
| steps: | |
| - uses: actions/checkout@v6 | |
| - uses: actions/setup-python@v6 | |
| with: | |
| python-version: ${{ env.PYTHON_VERSION }} | |
| - name: Extract release notes | |
| run: | | |
| VERSION=${GITHUB_REF#refs/tags/v} | |
| python scripts/extract_release_notes.py $VERSION > current_release_notes.md | |
| - uses: softprops/action-gh-release@v2 | |
| with: | |
| body_path: current_release_notes.md | |
| draft: false | |
| prerelease: ${{ contains(github.ref, 'alpha') || contains(github.ref, 'beta') || contains(github.ref, 'rc') }} | |
| generate_release_notes: true | |
| deploy-docs: | |
| name: Deploy documentation | |
| needs: [create-release] | |
| uses: ./.github/workflows/docs.yaml | |
| with: | |
| deploy: true | |
| version: ${{ github.ref_name }} |