Skip to content

update actions/upload-artifact and download-artifact to v4 #22

update actions/upload-artifact and download-artifact to v4

update actions/upload-artifact and download-artifact to v4 #22

Workflow file for this run

name: Release
on:
push:
tags:
- "v*.*.*"
- "v*.*.*-rc*"
- "release-test"
jobs:
create-release:
name: create-release
runs-on: ubuntu-latest
steps:
- name: Inject slug/short variables
uses: rlespinasse/[email protected]
- name: Create artifacts directory
run: mkdir artifacts
- name: Create Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ env.GITHUB_REF_SLUG }}
release_name: Release ${{ env.GITHUB_REF_SLUG }}
draft: false
prerelease: false
- name: Save release upload URL to artifact
run: echo "${{ steps.create_release.outputs.upload_url }}" > artifacts/release-upload-url
- name: Save version number to artifact
run: echo "${{ env.GITHUB_REF_SLUG }}" > artifacts/release-version
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: artifacts
path: artifacts
build-release:
name: build-release
needs: ["create-release"]
runs-on: ${{ matrix.os }}
env:
builder_image: meldron/psonoci_builder
strategy:
matrix:
build: [linux, linux-armv7, linux-aarch64, macos, win-gnu, win-msvc]
include:
- build: linux
os: ubuntu-22.04
target: x86_64-unknown-linux-musl
target_type: unix
- build: linux-armv7
os: ubuntu-22.04
target: armv7-unknown-linux-gnueabihf
target_type: unix
- build: linux-armv7-musl
os: ubuntu-22.04
target: armv7-unknown-linux-musleabihf
target_type: unix
use_cross: true
- build: linux-aarch64
os: ubuntu-22.04
target: aarch64-unknown-linux-musl
target_type: unix
- build: macos
os: macos-latest
target: x86_64-apple-darwin
target_type: unix
- build: macos-aarch64
os: macos-latest
target: aarch64-apple-darwin
target_type: unix
use_cross: false
- build: win-gnu
os: windows-2019
target: x86_64-pc-windows-gnu
target_type: windows
- build: win-msvc
os: windows-2019
target: x86_64-pc-windows-msvc
target_type: windows
steps:
- uses: actions/checkout@v2
- name: install rust
uses: actions-rs/toolchain@v1
with:
toolchain: stable
target: ${{ matrix.target }}
override: true
- name: Pull docker image used by cross
if: matrix.os == 'ubuntu-22.04'
run: docker pull $builder_image:${{ matrix.target }}
# - name: Build docker image used by cross
# if: matrix.target != 'x86_64-pc-windows-gnu'
# run: docker build build_files --cache-from $builder_image:${{ matrix.target }} --file build_files/Dockerfile-${{ matrix.target }} --tag $builder_image:${{ matrix.target }}
- name: build with cross
uses: actions-rs/cargo@v1
if: matrix.os == 'ubuntu-22.04'
with:
use-cross: true
command: build
args: --release --target ${{ matrix.target }}
- name: build with cargo
uses: actions-rs/cargo@v1
if: matrix.os != 'ubuntu-22.04'
with:
use-cross: false
command: build
args: --release --target ${{ matrix.target }}
- name: Get release download URL
uses: actions/download-artifact@v4
with:
name: artifacts
path: artifacts
- name: Set release upload URL and release version
shell: bash
run: |
release_upload_url="$(cat artifacts/release-upload-url)"
echo "RELEASE_UPLOAD_URL=$release_upload_url" >> $GITHUB_ENV
echo "release upload url: $RELEASE_UPLOAD_URL"
release_version="$(cat artifacts/release-version)"
echo "RELEASE_VERSION=$release_version" >> $GITHUB_ENV
echo "release version: $RELEASE_VERSION"
- name: Import GPG key
id: import_gpg
uses: crazy-max/ghaction-import-gpg@v3
with:
gpg-private-key: ${{ secrets.GPG_PRIVATE_KEY }}
passphrase: ${{ secrets.GPG_PRIVATE_KEY_PASSPHRASE }}
- name: Build archive
shell: bash
run: |
staging="psonoci-${{ env.RELEASE_VERSION }}-${{ matrix.target }}"
mkdir -p "$staging"
if [ "${{ matrix.target_type }}" = "windows" ]; then
cp "target/${{ matrix.target }}/release/psonoci.exe" "$staging/"
7z a "$staging.zip" "$staging"
gpg --armor --detach-sig -u [email protected] "$staging.zip"
echo "ASSET=$staging.zip" >> $GITHUB_ENV
echo "ASSET_SIG=$staging.zip.asc" >> $GITHUB_ENV
else
cp "target/${{ matrix.target }}/release/psonoci" "$staging/"
tar czf "$staging.tar.gz" "$staging"
gpg --armor --detach-sig -u [email protected] "$staging.tar.gz"
echo "ASSET=$staging.tar.gz" >> $GITHUB_ENV
echo "ASSET_SIG=$staging.tar.gz.asc" >> $GITHUB_ENV
fi
- name: Upload release archive
uses: actions/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ env.RELEASE_UPLOAD_URL }}
asset_path: ${{ env.ASSET }}
asset_name: ${{ env.ASSET }}
asset_content_type: application/octet-stream
- name: Upload release archive signature
uses: actions/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ env.RELEASE_UPLOAD_URL }}
asset_path: ${{ env.ASSET_SIG }}
asset_name: ${{ env.ASSET_SIG }}
asset_content_type: application/pgp-signature