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