Update publish-release.yml

This commit is contained in:
Adel Salakh 2025-05-14 22:28:25 +02:00 committed by GitHub
parent a395660e67
commit 19e70ffc69
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 87 additions and 104 deletions

View File

@ -1,135 +1,118 @@
name: Publish Release name: Publish Release
run-name: ${{ github.event.pull_request.head.ref }} run-name: Release ${{ github.event.inputs.version }}
on: on:
pull_request_target: workflow_dispatch:
branches: inputs:
- master version:
types: description: 'Release version (e.g. v1.2.3)'
- closed required: true
type: string
permissions: permissions:
contents: write contents: write
pull-requests: write
jobs: jobs:
publish: publish:
if: github.event.pull_request.merged && startsWith(github.event.pull_request.head.ref, 'release/')
runs-on: ubuntu-latest runs-on: ubuntu-latest
outputs: outputs:
tag: ${{ steps.tag.outputs.version }} tag: ${{ steps.tag.outputs.version }}
steps: steps:
- name: Check out code - name: Check out code
uses: actions/checkout@v4 uses: actions/checkout@v4
with: with:
ref: ${{ github.event.pull_request.merge_commit_sha }} fetch-depth: 0
fetch-depth: 0 fetch-tags: true
fetch-tags: true
- name: Tag release - name: Tag release
run: | id: tag
# Set up github-actions[bot] user run: |
git config --local user.name "github-actions[bot]" # Set up github-actions[bot] user
git config --local user.email "github-actions[bot]@users.noreply.github.com" git config --local user.name "github-actions[bot]"
git config --local user.email "github-actions[bot]@users.noreply.github.com"
# Get the version from the branch name # Use version from input
branch="${{ github.event.pull_request.head.ref }}" version="${{ github.event.inputs.version }}"
version="${branch#release/}" echo "Tagging release $version"
echo ${version}
# Tag and create release # Create annotated tag
git tag -a "${version}" -m "Release ${version}" git tag -a "$version" -m "Release $version"
echo "version=${version}" >> $GITHUB_OUTPUT echo "version=$version" >> $GITHUB_OUTPUT
id: tag
- name: Set up go - name: Set up Go
uses: actions/setup-go@v5 uses: actions/setup-go@v5
with: with:
go-version-file: go.mod go-version-file: go.mod
- name: Get dependencies - name: Get dependencies
env: env:
# renovate: datasource=github-tags depName=golangci/golangci-lint GOLANGCI_LINT_VERSION: v1.64.8
GOLANGCI_LINT_VERSION: v1.64.8 run: |
run: | curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin ${GOLANGCI_LINT_VERSION}
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin ${GOLANGCI_LINT_VERSION} curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter chmod +x ./cc-test-reporter
chmod +x ./cc-test-reporter go mod download
# Install go dependencies - name: Build Artifacts
go mod download run: make release
- name: Build Artifacts - name: Upload Artifacts
run: make release if: failure()
uses: actions/upload-artifact@v4
with:
name: oauth2-proxy-artifacts
path: |
release/*.tar.gz
release/*.txt
# Upload artifacts in case of workflow failure - name: Push tag
- name: Upload Artifacts run: git push origin "${{ steps.tag.outputs.version }}"
uses: actions/upload-artifact@v4
with:
name: oauth2-proxy-artifacts
path: |
release/*.tar.gz
release/*.txt
- name: Create release - name: Create GitHub release
env: env:
GH_TOKEN: ${{ github.token }} GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: | run: |
# Get version from tag version=${{ steps.tag.outputs.version }}
version=$(git describe --tags --abbrev=0) numericVersion="${version#v}"
notes=$(sed -n "/^# ${numericVersion}$/,/^# /{ /# ${numericVersion}$/d; /# /!p }" CHANGELOG.md)
# Extract CHANGELOG gh release create "$version" \
numericVersion="${version#v}" --title "$version" \
notes=$(sed -E "/^# (v|V)$numericVersion$/,/^# (v|V)/!d;//d" CHANGELOG.md) --notes "$notes" \
--prerelease \
# Publish release tag && gh release upload "$version" release/*.tar.gz release/*.txt
git push origin "${version}"
# Create github release
gh release create "${version}" \
--title "${version}" \
--notes "${notes}" \
--prerelease
# Upload artifacts
gh release upload "${version}" release/*.tar.gz
gh release upload "${version}" release/*.txt
docker: docker:
needs: publish needs: publish
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: Check out code
uses: actions/checkout@v4
with:
ref: ${{ needs.publish.outputs.tag }}
fetch-depth: 0
fetch-tags: true
- name: Check out code - name: Configure AWS credentials
uses: actions/checkout@v4 uses: aws-actions/configure-aws-credentials@v4
with: with:
ref: ${{ needs.publish.outputs.tag }} role-to-assume: ${{ vars.AWS_ECR_ROLE }}
fetch-depth: 0 aws-region: ${{ vars.AWS_REGION }}
fetch-tags: true
- name: Configure AWS credentials - name: Set up QEMU
uses: aws-actions/configure-aws-credentials@v4 uses: docker/setup-qemu-action@v3
with:
role-to-assume: ${{ vars.AWS_ECR_ROLE }}
aws-region: ${{ vars.AWS_REGION }}
- name: Set up QEMU - name: Set up Docker Buildx
uses: docker/setup-qemu-action@v3 id: buildx
uses: docker/setup-buildx-action@v3
- name: Set up Docker Buildx - name: Login to ECR
id: buildx id: ecr_login
uses: docker/setup-buildx-action@v3 uses: aws-actions/amazon-ecr-login@v1
with:
mask-password: 'true'
- name: Login to ECR - name: Build images
id: ecr_login run: make build-docker-all
uses: aws-actions/amazon-ecr-login@v1
with:
mask-password: 'true'
- name: Build images - name: Push images
run: | run: make push-docker-all
make build-docker-all
- name: Push images
run: |
make push-docker-all