Skip to content

Commit

Permalink
fix(ci): release process
Browse files Browse the repository at this point in the history
Signed-off-by: vados <[email protected]>
  • Loading branch information
t3hmrman committed Dec 11, 2023
1 parent 8811a75 commit 281f882
Show file tree
Hide file tree
Showing 6 changed files with 54 additions and 61 deletions.
65 changes: 41 additions & 24 deletions .github/workflows/build-and-test/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,6 @@ inputs:
default: false
description: |
Desired artifact name (will replace the natural name)
artifact-name:
type: string
description: |
Desired artifact name (will replace the natural name)
rust-container-version:
type: string
default: 1.73
Expand All @@ -36,6 +32,9 @@ inputs:
cargo-env-profile:
type: string
default: ci
user:
type: string
default: idkit
outputs: {}
runs:
using: "composite"
Expand Down Expand Up @@ -86,33 +85,38 @@ runs:
- name: Add git safe dir
shell: bash
run: |
git config --global --add safe.directory /__w/pg_idkit/pg_idkit
su idkit -c "git config --global --add safe.directory /__w/pg_idkit/pg_idkit"
# Run cargo build
- name: Run cargo test
# Run cargo check
- name: Run cargo check
shell: bash
env:
CARGO_HOME: ${{ inputs.cargo-home-dir }}
CARGO_TARGET_DIR: ${{ inputs.cargo-target-dir }}
SCCACHE_DIR: ${{ inputs.sccache-dir }}
CARGO_BUILD_RUSTC_WRAPPER: ${{ inputs.cargo-build-rustc-wrapper }}
CARGO_HOME: ${{ inputs.cargo-home-dir }}
CARGO_INCREMENTAL: ${{ inputs.cargo-env-incrmental }}
CARGO_PROFILE: ${{ inputs.cargo-profile }}
CARGO_TARGET_DIR: ${{ inputs.cargo-target-dir }}
PGRX_PKG_PATH_PREFIX: ${{ inputs.cargo-target-dir }}
SCCACHE_DIR: ${{ inputs.sccache-dir }}
USER: ${{ inputs.user }}
run: |
su idkit -c "cargo build"
su idkit -c "cargo check"
# Run cargo check
- name: Run cargo check
# Run cargo build
- name: Run cargo test
shell: bash
env:
CARGO_HOME: ${{ inputs.cargo-home-dir }}
CARGO_TARGET_DIR: ${{ inputs.cargo-target-dir }}
SCCACHE_DIR: ${{ inputs.sccache-dir }}
CARGO_BUILD_RUSTC_WRAPPER: ${{ inputs.cargo-build-rustc-wrapper }}
CARGO_HOME: ${{ inputs.cargo-home-dir }}
CARGO_INCREMENTAL: ${{ inputs.cargo-env-incrmental }}
CARGO_PROFILE: ${{ inputs.cargo-profile }}
CARGO_TARGET_DIR: ${{ inputs.cargo-target-dir }}
PGRX_PKG_PATH_PREFIX: ${{ inputs.cargo-target-dir }}
SCCACHE_DIR: ${{ inputs.sccache-dir }}
USER: ${{ inputs.user }}
run: |
su idkit -c "cargo check"
su idkit -c "cargo build"
# Run cargo test
- name: Run cargo test
Expand All @@ -124,17 +128,16 @@ runs:
CARGO_BUILD_RUSTC_WRAPPER: ${{ inputs.cargo-build-rustc-wrapper }}
CARGO_INCREMENTAL: ${{ inputs.cargo-env-incrmental }}
CARGO_PROFILE: ${{ inputs.cargo-profile }}
USER: ${{ inputs.user }}
run: |
su idkit -c "cargo test"
#############
# Artifacts #
#############

# Run cargo test
- name: Build a package
- name: Reinstall deps due to GLIBC issue
if: ${{ inputs.artifact-upload }}
id: package
shell: bash
env:
CARGO_HOME: ${{ inputs.cargo-home-dir }}
Expand All @@ -143,16 +146,30 @@ runs:
CARGO_BUILD_RUSTC_WRAPPER: ${{ inputs.cargo-build-rustc-wrapper }}
CARGO_INCREMENTAL: ${{ inputs.cargo-env-incrmental }}
CARGO_PROFILE: ${{ inputs.cargo-profile }}
USER: ${{ inputs.user }}
PGRX_PKG_PATH_PREFIX: ${{ inputs.cargo-target-dir }}
run: |
su idkit -c "cargo install --force cargo-get cargo-edit"
# Run cargo test
- name: Build a package
if: ${{ inputs.artifact-upload }}
shell: bash
env:
CARGO_BUILD_RUSTC_WRAPPER: ${{ inputs.cargo-build-rustc-wrapper }}
CARGO_HOME: ${{ inputs.cargo-home-dir }}
CARGO_INCREMENTAL: ${{ inputs.cargo-env-incrmental }}
CARGO_PROFILE: ${{ inputs.cargo-profile }}
CARGO_TARGET_DIR: ${{ inputs.cargo-target-dir }}
PGRX_PKG_PATH_PREFIX: ${{ inputs.cargo-target-dir }}
SCCACHE_DIR: ${{ inputs.sccache-dir }}
USER: ${{ inputs.user }}
run: |
su idkit -c "cargo install --force just cargo-get"
su idkit -c "just package"
tar -cvf pg_idkit-$(just print-version).zip $(just print-pkg-output-dir)
echo filename=pg_idkit-v$(just print-version).zip >> $GITHUB_OUTPUT
# Upload artifact
- name: Upload artifact
if: ${{ inputs.artifact-upload }}
uses: actions/upload-artifact@v3
with:
name: ${{ inputs.artifact-name || steps.package.outputs.filename }}
path: ${{ steps.package.outputs.filename }}
path: pg_idkit-*.tar.gz
39 changes: 4 additions & 35 deletions .github/workflows/release.yml → .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,10 @@ jobs:
steps:
- uses: actions/checkout@v3

- name: Get version
id: detect-version
run: |
echo value=$(just print-version) >> $GITHUB_OUTPUT
- name: Build the RPM (reuse workflow)
uses: ./.github/workflows/build-rpm
with:
artifact-upload: true
artifact-name: pg_idkit-v${{ steps.detect-version.outputs.value }}.rpm

build-zip:
runs-on: ubuntu-latest
Expand All @@ -33,16 +27,10 @@ jobs:
steps:
- uses: actions/checkout@v3

- name: Get version
id: detect-version
run: |
echo value=$(just print-version) >> $GITHUB_OUTPUT
- name: Build the package (reuse workflow)
uses: ./.github/workflows/build-and-test
with:
artifact-upload: true
artifact-name: pg_idkit-v${{ steps.detect-version.outputs.value }}.zip

release:
runs-on: ubuntu-latest
Expand All @@ -55,37 +43,18 @@ jobs:
# Checkout the repository
- uses: actions/checkout@v3

# Install deps
- uses: Swatinem/rust-cache@v2
- name: Install cargo-release
uses: taiki-e/install-action@v1
with:
tool: just

# Detect version
- name: Detect version
id: detect-version
env:
VERSION: ${{ inputs.version }}
run: |
echo value=$(just print-version) >> $GITHUB_OUTPUT
# Download artifacts
- uses: actions/download-artifact@v3
with:
name: pg_idkit-${{ steps.detect-version.outputs.value }}.rpm
# Download all artifacts
- uses: actions/download-artifact@v3
with:
name: pg_idkit-${{ steps.detect-version.outputs.value }}.zip
path: artifacts

# Create release (pre-release if we're prepping)
- name: Create release
uses: softprops/action-gh-release@v1
with:
body_path: CHANGELOG.md
body_path: CHANGELOG
prerelease: ${{ startsWith(github.ref, 'refs/heads/prep-release') }}
draft: true
generate_release_notes: true
files: |
pg_idkit-${{ steps.detect-version.outputs.value }}.rpm
pg_idkit-${{ steps.detect-version.outputs.value }}.zip
./artifacts/*/*
File renamed without changes.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,6 @@
secrets/docker/.token_seed
secrets/docker/.token_seed.lock
secrets/docker/buildx/

# Releases
/pkg
1 change: 0 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ codegen-units = 1

[profile.ci]
inherits = "test"
incremental = false

[package.metadata.generate-rpm]
assets = []
Expand Down
7 changes: 6 additions & 1 deletion Justfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ user := env_var('USER')

docker := env_var_or_default("DOCKER", "docker")
git := env_var_or_default("GIT", "git")
tar := env_var_or_default("TAR", "tar")
strip := env_var_or_default("STRIP", "strip")
just := env_var_or_default("JUST", just_executable())

Expand All @@ -28,7 +29,8 @@ pkg_pg_version := env_var_or_default("PKG_PG_VERSION", "15.5")
pkg_pg_config_path := env_var_or_default("PKG_PG_CONFIG_PATH", "~/.pgrx/" + pkg_pg_version + "/pgrx-install/bin/pg_config")

pgrx_pg_version := env_var_or_default("PGRX_PG_VERSION", "pg15")
pgrx_pkg_output_dir := "target" / "release" / "pg_idkit-" + pgrx_pg_version / "home" / user / ".pgrx" / pkg_pg_version / "pgrx-install"
pgrx_pkg_path_prefix := env_var_or_default("PGRX_PKG_PATH_PREFIX", "target")
pgrx_pkg_output_dir := pgrx_pkg_path_prefix / "release" / "pg_idkit-" + pgrx_pg_version / "home" / user / ".pgrx" / pkg_pg_version / "pgrx-install"

default:
{{just}} --list
Expand Down Expand Up @@ -104,6 +106,9 @@ build-test-watch: _check-tool-cargo _check-tool-cargo-watch

package:
PGRX_IGNORE_RUST_VERSIONS=y {{cargo}} pgrx package --pg-config {{pkg_pg_config_path}}
mkdir -p pkg/pg_idkit-$({{just}} print-version)
cp -r $({{just}} print-pkg-output-dir)/* pkg/pg_idkit-$({{just}} print-version)
{{tar}} -C pkg -cvf pg_idkit-$(just print-version).tar.gz pg_idkit-$({{just}} print-version)

print-pkg-output-dir:
echo -n {{pgrx_pkg_output_dir}}
Expand Down

0 comments on commit 281f882

Please sign in to comment.