mirror of
https://github.com/opentofu/setup-opentofu.git
synced 2025-12-31 15:02:19 +00:00
123 lines
4.1 KiB
YAML
123 lines
4.1 KiB
YAML
name: release
|
|
|
|
on:
|
|
workflow_dispatch:
|
|
inputs:
|
|
versionNumber:
|
|
description: 'Release version number (v#.#.#)'
|
|
type: string
|
|
required: true
|
|
|
|
permissions:
|
|
contents: read # Changelog commit operations use service account PAT
|
|
|
|
env:
|
|
CI_COMMIT_AUTHOR: opentofu-ci
|
|
CI_COMMIT_EMAIL: none@tofu.org
|
|
|
|
jobs:
|
|
major-version:
|
|
runs-on: ubuntu-latest
|
|
outputs:
|
|
version: ${{ steps.major-version.outputs.version }}
|
|
steps:
|
|
- id: major-version
|
|
run: echo "version=$(echo "${{ inputs.versionNumber }}" | cut -d. -f1)" >> "$GITHUB_OUTPUT"
|
|
|
|
changelog-version:
|
|
runs-on: ubuntu-latest
|
|
outputs:
|
|
version: ${{ steps.changelog-version.outputs.version }}
|
|
steps:
|
|
- id: changelog-version
|
|
run: echo "version=$(echo "${{ inputs.versionNumber }}" | cut -c 2-)" >> "$GITHUB_OUTPUT"
|
|
|
|
changelog:
|
|
needs: changelog-version
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
- uses: miniscruff/changie-action@v2
|
|
with:
|
|
version: latest
|
|
args: batch ${{ needs.changelog-version.outputs.version }}
|
|
- uses: miniscruff/changie-action@v2
|
|
with:
|
|
version: latest
|
|
args: merge
|
|
- name: Git push changelog
|
|
run: |
|
|
git config --global user.name "${{ env.CI_COMMIT_AUTHOR }}"
|
|
git config --global user.email "${{ env.CI_COMMIT_EMAIL }}"
|
|
git add .
|
|
git commit -a -m "Update changelog"
|
|
git push "https://${{ env.CI_COMMIT_AUTHOR }}:${{ secrets.TF_DEVEX_COMMIT_GITHUB_TOKEN }}@github.com/${{ github.repository }}.git"
|
|
|
|
update-package-version:
|
|
needs: changelog
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v4
|
|
with:
|
|
fetch-depth: 0
|
|
ref: ${{ github.ref }}
|
|
persist-credentials: false
|
|
|
|
- name: Set up Node.js
|
|
uses: actions/setup-node@v3
|
|
with:
|
|
node-version: 18
|
|
- name: Update package version
|
|
run: npm version "${{ inputs.versionNumber }}" --git-tag-version false
|
|
- name: Git push
|
|
run: |
|
|
git config --global user.name "${{ env.CI_COMMIT_AUTHOR }}"
|
|
git config --global user.email "${{ env.CI_COMMIT_EMAIL }}"
|
|
git add .
|
|
git commit -a -m "Update package version"
|
|
git push "https://${{ env.CI_COMMIT_AUTHOR }}:${{ secrets.TF_DEVEX_COMMIT_GITHUB_TOKEN }}@github.com/${{ github.repository }}.git"
|
|
|
|
release-tag:
|
|
needs: [ update-package-version, major-version ]
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v4
|
|
with:
|
|
fetch-depth: 0
|
|
ref: ${{ github.ref }}
|
|
persist-credentials: false
|
|
|
|
- name: Git push release tag
|
|
run: |
|
|
git config --global user.name "${{ env.CI_COMMIT_AUTHOR }}"
|
|
git config --global user.email "${{ env.CI_COMMIT_EMAIL }}"
|
|
# here is the only essential thing in that workflow
|
|
git tag "${{ inputs.versionNumber }}"
|
|
git tag -f "${{ needs.major-version.outputs.version }}"
|
|
git push "https://${{ env.CI_COMMIT_AUTHOR }}:${{ secrets.TF_DEVEX_COMMIT_GITHUB_TOKEN }}@github.com/${{ github.repository }}.git" "${{ inputs.versionNumber }}"
|
|
git push "https://${{ env.CI_COMMIT_AUTHOR }}:${{ secrets.TF_DEVEX_COMMIT_GITHUB_TOKEN }}@github.com/${{ github.repository }}.git" -f "${{ needs.major-version.outputs.version }}"
|
|
|
|
release:
|
|
needs: [ changelog-version, release-tag ]
|
|
runs-on: ubuntu-latest
|
|
permissions:
|
|
contents: write # Needed to create GitHub release
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
with:
|
|
ref: ${{ inputs.versionNumber }}
|
|
fetch-depth: 0
|
|
|
|
- name: Generate Release Notes
|
|
run: |
|
|
cd .changes
|
|
sed -e "1{/# /d;}" -e "2{/^$/d;}" ${{ needs.changelog-version.outputs.version }}.md > /tmp/release-notes.txt
|
|
|
|
- name: GH Release
|
|
run: |
|
|
gh release create "${{ inputs.versionNumber }}" --notes-file /tmp/release-notes.txt --title "${{ inputs.versionNumber }}"
|
|
env:
|
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
|