forked from prometheus-community/postgres_exporter
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
7326d15
commit 19ea2bc
Showing
16 changed files
with
684 additions
and
77 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
name: Calculate new tag | ||
|
||
on: | ||
workflow_call: | ||
outputs: | ||
tag: | ||
description: "The the next semantic version tag based on commit messages." | ||
value: ${{ jobs.calculate-tag.outputs.tag }} | ||
inputs: | ||
head_ref: | ||
description: "Head ref to be used as pre-release suffix" | ||
type: string | ||
default: "${{ github.head_ref }}" | ||
f3_tag: | ||
description: "Additional tag to be prefixed to the latest upstream release tag" | ||
type: string | ||
default: "${{ github.sha }}" | ||
|
||
jobs: | ||
calculate-tag: | ||
runs-on: ubuntu-20.04 | ||
permissions: read-all | ||
outputs: | ||
tag: "${{ steps.tag.outputs.tag }}" | ||
steps: | ||
- uses: actions/checkout@8f4b7f84864484a7bf31766abe9204da3cbe65b3 # v3.5.0 | ||
with: | ||
fetch-depth: 0 | ||
|
||
- name: Determine latest upstream release tag | ||
id: latest_tag | ||
if: "!contains(github.ref,'refs/tags/')" | ||
run: | | ||
latest_tag=$(git describe --abbrev=0 --tags) | ||
echo "latest_tag=$latest_tag" >> $GITHUB_OUTPUT | ||
- name: Get the tag name | ||
if: contains(github.ref, 'refs/tags/') | ||
id: tag_name | ||
run: echo "latest_tag=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT | ||
|
||
- name: Calculate pre-release suffix | ||
id: tag-suffix | ||
run: | | ||
echo "event name ${{ github.event_name }}" | ||
SUFFIX="${{ inputs.head_ref }}" | ||
if [[ "${{ github.event_name }}" = "push" && "${{ github.ref_type }}" = "branch" && "${{ github.ref_name }}" = "builder" ]]; then | ||
SUFFIX="release-$(date +%Y-%m-%d)" | ||
fi | ||
underscores_and_slashes_to_dashes_suffix="${SUFFIX//[\/_]/-}" | ||
echo "tag-suffix=-${underscores_and_slashes_to_dashes_suffix}" >> $GITHUB_OUTPUT | ||
- name: Compute next tag | ||
id: tag | ||
run: | | ||
latest_tag="${{ steps.latest_tag.outputs.latest_tag }}" | ||
tag="${latest_tag}-f3-${{steps.tag-suffix.outputs.tag-suffix}}" | ||
echo "tag=$tag" >> $GITHUB_OUTPUT |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
name: CI | ||
Check failure on line 1 in .github/workflows/ci.yaml GitHub Actions / test.github/workflows/ci.yaml#L1
Check failure on line 1 in .github/workflows/ci.yaml GitHub Actions / calculate-tag / calculate-tag.github/workflows/ci.yaml#L1
|
||
on: | ||
push: | ||
branches: | ||
- master | ||
tags: | ||
- '**' | ||
pull_request: | ||
|
||
jobs: | ||
calculate-tag: | ||
uses: ./.github/workflows/calculate-tag.yaml | ||
test: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout Code | ||
uses: actions/checkout@8f4b7f84864484a7bf31766abe9204da3cbe65b3 # v3.5.0 | ||
- name: Setup Golang | ||
uses: actions/setup-go@4d34df0c2316fe8122ab82dc22947d607c0c91f9 # v4.0.0 | ||
with: | ||
go-version-file: go.mod | ||
- name: Test | ||
run: make test | ||
build: | ||
runs-on: ubuntu-latest | ||
needs: [ calculate-tag, test ] | ||
steps: | ||
- name: Checkout Code | ||
uses: actions/checkout@8f4b7f84864484a7bf31766abe9204da3cbe65b3 # v3.5.0 | ||
- name: Setup Golang | ||
uses: actions/setup-go@4d34df0c2316fe8122ab82dc22947d607c0c91f9 # v4.0.0 | ||
with: | ||
go-version-file: go.mod | ||
- name: Build | ||
run: make crossbuild | ||
- name: Package | ||
run: make crossbuild-tarballs | ||
- name: Archive artifacts | ||
uses: actions/upload-artifact@v3 | ||
with: | ||
name: dist | ||
path: ./.build/*.tar.gz | ||
|
||
publish: | ||
runs-on: ubuntu-latest | ||
needs: [ calculate-tag, build ] | ||
permissions: write-all | ||
if: contains(github.event.head_commit.message, 'pre-release') || startsWith(github.base_ref, '/refs/tags') | ||
steps: | ||
- name: Download artifacts | ||
uses: actions/download-artifact@v3 | ||
with: | ||
name: dist | ||
- name: Download artifacts | ||
run: ls -ltr | ||
- name: Create GH release | ||
uses: softprops/action-gh-release@v1 | ||
id: release | ||
with: | ||
generate_release_notes: true | ||
target_commitish: "${{ github.base_ref }}" | ||
tag_name: ${{ needs.calculate-tag.outputs.tag }} | ||
prerelease: "${{ github.event_name == 'pull_request' }}" | ||
files: | | ||
*.tar.gz |
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Oops, something went wrong.