Update build pipelines to support RC builds

This commit is contained in:
Ben Sarmiento
2024-05-28 10:00:21 +02:00
parent d8b0bfc9f4
commit baf33c9e28
2 changed files with 21 additions and 53 deletions

View File

@@ -19,6 +19,14 @@ jobs:
with:
go-version: '1.21'
- name: Cache Go Modules
uses: actions/cache@v3
with:
path: |
~/.cache/go-build
~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
- name: Check out code
uses: actions/checkout@v4
@@ -31,7 +39,6 @@ jobs:
- name: Cross-compile with xgo
uses: crazy-max/ghaction-xgo@v3
if: ${{ !startsWith(github.ref, 'refs/tags/v') }}
with:
xgo_version: latest
go_version: 1.21
@@ -50,26 +57,6 @@ jobs:
buildmode: default
trimpath: true
- name: Cross-compile with xgo
uses: crazy-max/ghaction-xgo@v3
if: ${{ startsWith(github.ref, 'refs/tags/v') }}
with:
xgo_version: latest
go_version: 1.21
pkg: cmd/zurg
dest: artifacts
prefix: zurg
v: false
x: false
race: false
ldflags: >
-s -w
-X 'github.com/debridmediamanager/zurg/internal/version.BuiltAt=${{ steps.prep.outputs.built_at }}'
-X 'github.com/debridmediamanager/zurg/internal/version.GitCommit=${{ steps.prep.outputs.git_commit }}'
-X 'github.com/debridmediamanager/zurg/internal/version.Version=${{ steps.prep.outputs.version }}'
buildmode: default
trimpath: true
- name: Compress artifacts
run: |
mkdir -p compressed_artifacts
@@ -112,20 +99,25 @@ jobs:
name: compiled-binaries
path: compressed_artifacts
- name: Publish to zurg-testing
- name: Publish to zurg or zurg-testing
run: |
git config --global user.name "Zurg"
git config --global user.email "zurg@debridmediamanager.com"
git lfs install
if [[ "${{ steps.version.outputs.version }}" == *"-rc."* ]]; then
git remote set-url origin git@github.com:debridmediamanager/zurg.git
else
git remote set-url origin git@github.com:debridmediamanager/zurg-testing.git
fi
- name: Create Release in Target Repository
uses: actions/github-script@v7
if: ${{ startsWith(github.ref, 'refs/tags/v') }}
with:
github-token: ${{ secrets.TOKEN }}
script: |
const ownerName = 'debridmediamanager';
const repoName = 'zurg-testing';
const repoName = '${{ github.ref.includes("-rc.") ? "zurg" : "zurg-testing" }}';
const tagName = '${{ steps.version.outputs.version }}';
const releaseName = `${tagName}`;
@@ -159,7 +151,7 @@ jobs:
${sponsorshipDetails}
[version history](https://github.com/debridmediamanager/zurg-testing/wiki/History)
[version history](https://github.com/debridmediamanager/${repoName}/wiki/History)
`;
const response = await github.rest.repos.createRelease({

View File

@@ -35,6 +35,8 @@ jobs:
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx-${{ github.sha }}
restore-keys: |
${{ runner.os }}-buildx-
- name: Log in to GitHub Container Registry
uses: docker/login-action@v3
@@ -43,16 +45,14 @@ jobs:
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
# private image
- name: Extract metadata (tags, labels) for Docker
if: ${{ !startsWith(github.ref, 'refs/tags/v') }}
id: meta
uses: docker/metadata-action@v5
with:
images: ghcr.io/${{ github.repository }}
images: |
ghcr.io/${{ github.repository }}${{ github.ref.contains('-rc.') ? '' : '-testing' }}
- name: Build and push Docker image
if: ${{ !startsWith(github.ref, 'refs/tags/v') }}
uses: docker/build-push-action@v5
with:
context: .
@@ -66,27 +66,3 @@ jobs:
BuiltAt=${{ steps.buildvars.outputs.built_at }}
GitCommit=${{ steps.buildvars.outputs.git_commit }}
Version=${{ steps.buildvars.outputs.version }}
# public image
- name: Extract metadata (tags, labels) for Docker
if: ${{ startsWith(github.ref, 'refs/tags/v') }}
id: publicmeta
uses: docker/metadata-action@v5
with:
images: ghcr.io/${{ github.repository }}-testing
- name: Build and push Docker image
if: ${{ startsWith(github.ref, 'refs/tags/v') }}
uses: docker/build-push-action@v5
with:
context: .
platforms: linux/amd64,linux/arm64,linux/arm/v7
push: true
tags: ${{ steps.publicmeta.outputs.tags }}
labels: ${{ steps.publicmeta.outputs.labels }}
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache
build-args: |
BuiltAt=${{ steps.buildvars.outputs.built_at }}
GitCommit=${{ steps.buildvars.outputs.git_commit }}
Version=${{ steps.buildvars.outputs.version }}