build: update release process #15
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: | |
| branches: | |
| - 'main' | |
| jobs: | |
| release: | |
| runs-on: reveng-small | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Generate a token | |
| id: generate-token | |
| uses: actions/create-github-app-token@v1 | |
| with: | |
| app-id: ${{ vars.REVENG_APP_ID }} | |
| private-key: ${{ secrets.REVENG_APP_PRIVATE_KEY }} | |
| - name: Read version from file | |
| id: version | |
| run: | | |
| if [ ! -f ".sdk-version" ]; then | |
| echo "Error: .sdk-version file not found" | |
| exit 1 | |
| fi | |
| VERSION=$(cat .sdk-version | tr -d '\n\r' | xargs) | |
| if [ -z "$VERSION" ]; then | |
| echo "Error: .sdk-version file is empty" | |
| exit 1 | |
| fi | |
| echo "Found version: $VERSION" | |
| echo "version=$VERSION" >> $GITHUB_OUTPUT | |
| - name: Check if tag already exists | |
| id: check-tag | |
| run: | | |
| if git ls-remote --tags origin | grep -q "refs/tags/v${{ steps.version.outputs.version }}$"; then | |
| echo "Tag v${{ steps.version.outputs.version }} already exists" | |
| echo "tag_exists=true" >> $GITHUB_OUTPUT | |
| else | |
| echo "Tag v${{ steps.version.outputs.version }} does not exist" | |
| echo "tag_exists=false" >> $GITHUB_OUTPUT | |
| fi | |
| - name: Create and push tag | |
| if: steps.check-tag.outputs.tag_exists == 'false' | |
| env: | |
| GITHUB_TOKEN: ${{ steps.generate-token.outputs.token }} | |
| run: | | |
| git config user.name "github-actions[bot]" | |
| git config user.email "github-actions[bot]@users.noreply.github.com" | |
| TAG_NAME="v${{ steps.version.outputs.version }}" | |
| git tag "$TAG_NAME" | |
| git push origin "$TAG_NAME" | |
| echo "Created and pushed tag: $TAG_NAME" | |
| - name: Create GitHub release | |
| if: steps.check-tag.outputs.tag_exists == 'false' | |
| env: | |
| GITHUB_TOKEN: ${{ steps.generate-token.outputs.token }} | |
| run: | | |
| TAG_NAME="v${{ steps.version.outputs.version }}" | |
| gh release create "$TAG_NAME" \ | |
| --title "Release $TAG_NAME" \ | |
| --notes "Release $TAG_NAME" \ | |
| --verify-tag | |
| - name: Notify the releases channel about the release | |
| if: steps.check-tag.outputs.tag_exists == 'false' | |
| uses: slackapi/slack-github-action@v2.0.0 | |
| env: | |
| REPO_URL: "${{github.server_url}}/${{github.repository}}" | |
| RELEASE_URL: "${{github.server_url}}/${{github.repository}}/releases/tag/v${{ steps.version.outputs.version }}" | |
| with: | |
| webhook: ${{ secrets.RELEASES_SLACK_WEBHOOK }} | |
| webhook-type: incoming-webhook | |
| payload: | | |
| text: "<${{ env.RELEASE_URL }}|v${{ steps.version.outputs.version }}> has been released for <${{ env.REPO_URL }}|${{ github.repository }}>" |